AVAudioPlayer in not playing file from url?
I am trying to play a recorded file in AVAudioPlayer. It plays my Local recording fine but when I try to play the same file stored on server with a valid url it doesn't play any sound..?
I tried
NSURL *url = [NSURL URLWithString:self.filePathUrl];
NSData *memoData = [NSData dataWithContentsOfURL:url];
newPlayer = [[AVAudioPlayer alloc] initWithData:memoData error:nil];//[[AVAudioPlayer alloc] initWithContentsOfURL:url error: nil];
This is not working..
I am not understanding what happen while getting data from url. I am getting my data too开发者_运维问答. its length is not 0. and the file format on server is .caf only. Please help me to understand the issue.
Thanks.
You have to start the audioplayer
[newPlayer play];
The AVAudioPlayer can only play local files. See the Apple Developer page on AVAudioPlayer streaming support.
You could use Miguel's streaming audio player that uses an AudioQueue but I don't think you can seek or scrub the audio.
Hope this helps.
精彩评论