Resume AVPlayer video playback after app become active

后端 未结 5 1306
天涯浪人
天涯浪人 2021-02-02 15:53

I write custom player from AVPlayer for video playback. According to Apple docs set the video layer:

    self.player = [IPLPlayer new];
    self.player.playerLa         


        
5条回答
  •  清酒与你
    2021-02-02 16:42

    The trick is to detach all video layers from their players when the app did enter background and reattaching them when the app did become active again.

    So in your -applicationDidEnterBackground: you got to trigger a mechanism that results in

    avPlayerLayer.player = nil;
    

    and in your -applicationDidBecomeActive: you reattach the player like

    avPlayerLayer.player = self.avPlayer;
    

    Also have a look at this Tech Note (QA1668) from Apple.

提交回复
热议问题