0

i am trying to make an online audio player. but i can't paly audio using AVAudioPlayer object. Please Help Me. Thanks in Advance.

Here is my audio player code. ================>>

NSURL *url =[[NSURL alloc] initWithString:@"My Url"];

xPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
xPlayer.numberOfLoops = 0;
xPlayer.volume = 1.0f;

[xPlayer prepareToPlay];
[xPlayer play];

1 Answers1

1

Q: Does the AVAudioPlayer provide support for streaming audio content?

A: The AVAudioPlayer class does not provide support for streaming audio based on HTTP URL's. The URL used with initWithContentsOfURL: must be a File URL (file://). That is, a local path.

Source: https://developer.apple.com/library/ios/qa/qa1634/_index.html

Peter Lendvay
  • 565
  • 4
  • 22
  • Ohh, i'm trying with a http url, my bad. Thanks Peter. can you please Suggest me how can i play audio smoothly from url other then AVPlayer. – Zahid Hasan Apr 01 '15 at 12:08
  • Never done it personally. I'm pretty sure you can do it with AVPlayer rather, than AVAudioPlayer. Try looking into this link: http://stackoverflow.com/a/22216928/4716039 – Peter Lendvay Apr 01 '15 at 12:20