iOS AVPlayerViewController 区分用户操作以退出画中画模式

问题描述 投票:0回答:1

在我的 iOS 视频播放器中,当处于画中画模式 (PIP) 时,如何处理特定的用户操作,例如

close
restore
。现有的委托提供了一种方法来了解 PIP 模式何时停止,但我不希望在不同的用户操作上执行不同的行为:

  • 关闭 - 让控制器离开并保持关闭状态
  • 恢复 - 重新呈现播放器并继续播放

实现

AVPlayerViewControllerDelegate
后,无论用户点击哪个按钮,AVPlayerViewController都会调用以下函数:

playerViewControllerWillStopPictureInPicture
playerViewControllerDidStopPictureInPicture

我还定义了方法

pictureInPictureController
,但由于某种原因退出 PIP 模式时似乎没有被调用。

ios avplayerviewcontroller avkit picture-in-picture
1个回答
0
投票

要恢复播放器并继续播放,您应该使用

playerViewController(_:restoreUserInterfaceForPictureInPictureStopWithCompletionHandler:)
AVPictureInPictureControllerDelegate
方法。

此方法在

playerViewControllerWillStopPictureInPicture(_:)
playerViewControllerDidStopPictureInPicture(_:)
之前调用,如 Apple 文档中所述。

© www.soinside.com 2019 - 2024. All rights reserved.