Answer the question
In order to leave comments, you need to log in
How to fix avplayer playback in background on ios 8?
On ios 8, audio playback in the background using avplayer broke, after about 10 minutes of playback in the background, it stops.
Example:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSURL *streamingURL = [NSURL URLWithString:@"http://www.radiofmgold.be/stream.php?ext=pls"];
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:streamingURL];
[self setPlayerItem:playerItem];
AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem];
[player setAllowsExternalPlayback:NO];
[self setPlayer:player];
[player play];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];
return YES;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question