play audio from internet using AVAudioPlayer

Use AVPlayer to stream audio/video based on http url’s. It will work fine. AVAudioPlayer is for local files. Here’s the code NSURL *url = [NSURL URLWithString:url]; self.avAsset = [AVURLAsset URLAssetWithURL:url options:nil]; self.playerItem = [AVPlayerItem playerItemWithAsset:avAsset]; self.audioPlayer = [AVPlayer playerWithPlayerItem:playerItem]; [self.audioPlayer play];

Is it possible to test iOS4 multitasking/background music playing on the simulator?

I too had the same issue. In simulator the audio pauses and when you launch it back it resumes playback. But testing on device it worked perfectly and audio continued to play in background. The sample code which i have used is AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil]; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; [audioPlayer play];

AVAudioPlayer: How to Change the Playback Speed of Audio?

Now it is possible to change the playback speed. Sample code: player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:&err]; player.volume = 0.4f; player.enableRate = YES; //<– [player prepareToPlay]; [player setNumberOfLoops:0]; player.rate = 2.0f; //<– Playback Speed [player play]; enableRate is set to YES and you can change it. See more in the docs.

Slow start for AVAudioPlayer the first time a sound is played

The delay seems to be related to instantiating AVAudioPlayer for the first time. If I load any audio, run [audioPlayer prepareToPlay] and then immediately release it, the load times for all of my other audio is very close to imperceptible. So now I’m doing that in applicationDidFinishLaunching and everything else runs well. I can’t find … Read more