I experienced the same thing with this third-party application and could not find a solution for this, and then I tried using my own avplayer (not avaudioplayer), which gives you the ability to pass using the function :initWithURL . here is a link to the class, by the way: http://developer.apple.com/library/mac/#documentation/AVFoundation/Reference/AVPlayer_Class/Reference/Reference.html
Also here is my code for playing music:
NSURL *url = [[NSURL alloc] initWithString:sourceURL]; theItem = [AVPlayerItem playerItemWithURL:url]; theItem addObserver:self forKeyPath:@"status" options:0 context:nil]; theAudio = [AVPlayer playerWithPlayerItem:mainDelegate.theItem];
to catch if the player is ready for the game, you add an observer above, and then you can check it as:
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (object == theItem && [keyPath isEqualToString:@"status"]) { if(theItem.status == AVPlayerStatusReadyToPlay) { [theAudio play]; [theItem removeObserver:self forKeyPath:@"status"]; } else if(theItem.status == AVPlayerStatusFailed) { NSLog(@"%@" , mainDelegate.theItem.error.description); } else if(theItem.status == AVPlayerStatusUnknown) NSLog(@"unknown"); } }
Hope this helps.
iremk source share