3

I remove/restore the AVPlayerLayer and its associated AVPlayer, like apple suggest in the docs.

/* Remove the AVPlayerLayer from its associated AVPlayer
    once the app is in the background. */
- (void)applicationDidEnterBackground:(UIApplication *)application {
  MyPlayerLayerView *playerView = <#Get your player view#>;
  [[playerView playerLayer] setPlayer:nil]; // remove the player
}

/* Restore the AVPlayer when the app is active again. */
- (void)applicationDidBecomeActive:(UIApplication *)application {
  MyPlayerLayerView *playerView = <#Get your player view#>;
  [[playerView playerLayer] setPlayer:_player]; // restore the player
}

And the the music continue to play like it should but there is a little pause and play when switching to background/foreground.

The question is how to avoid it?

yogev
  • 41
  • 3

0 Answers0