Kapil Choubisa
Kapil Choubisa

Reputation: 5232

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.

Upvotes: 1

Views: 2427

Answers (2)

dcdroid
dcdroid

Reputation: 691

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.

Upvotes: 3

Thizzer
Thizzer

Reputation: 16663

You have to start the audioplayer

  [newPlayer play];

Upvotes: 5

Related Questions