iPad画中画随机调用restoreUserInterfaceForPictureInPictureStopWithCompletionHandler

iPad Picture in Picture Calling restoreUserInterfaceForPictureInPictureStopWithCompletionHandler Randomly

在我们的应用程序中,我们有一个通过 AVKit 的自定义播放器,支持 iPad 上的画中画多任务处理。

设置画中画后不久,似乎无缘无故地调用了 restoreUserInterfaceForPictureInPictureStopWithCompletionHandler 委托方法函数。

Apple's documentation 中说:

This method is called no matter how PiP ends, whether it is because the user ended playback, the user tapped the button to return ongoing video playback to your app, or the video finished playing on its own.

在这种情况下,用户没有结束播放,或者点击按钮 return 到应用中正在进行的视频,视频没有自行播放完。

画中画可以随机结束的其他原因是什么?

发生这种情况的一种情况是,如果您将 AVAudioSession 类别设置为环境,这将拆除画中画控制器,从而调用 restoreUserInterfaceForPictureInPictureStopWithCompletionHandler 委托方法。确保它保留在播放类别将确保画中画控制器不会被删除。