在我的 iOS 视频播放器中,当处于画中画模式 (PIP) 时,如何处理特定的用户操作,例如
close
或 restore
。现有的委托提供了一种方法来了解 PIP 模式何时停止,但我不希望在不同的用户操作上执行不同的行为:
实现
AVPlayerViewControllerDelegate
后,无论用户点击哪个按钮,AVPlayerViewController都会调用以下函数:
playerViewControllerWillStopPictureInPicture
playerViewControllerDidStopPictureInPicture
我还定义了方法
pictureInPictureController
,但由于某种原因退出 PIP 模式时似乎没有被调用。
要恢复播放器并继续播放,您应该使用
playerViewController(_:restoreUserInterfaceForPictureInPictureStopWithCompletionHandler:)
的AVPictureInPictureControllerDelegate
方法。
此方法在
playerViewControllerWillStopPictureInPicture(_:)
和 playerViewControllerDidStopPictureInPicture(_:)
之前调用,如 Apple 文档中所述。