开发者

AVAudioPlayer in not playing file from url?

开发者 https://www.devze.com 2023-03-02 17:50 出处:网络
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 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号