根据文档,当 AVPictureInPictureController 关闭时,将调用 willStop 和 didStop 委托方法以及restoreUserInterfaceForPictureInPictureStopWithCompletionHandler,无论它是如何关闭的。如何判断控制器是通过“X”按钮还是其他按钮关闭以返回常规播放?
小智 5
X按钮和恢复按钮之间的区别是:
点击恢复画中画按钮将触发
"pictureInPictureController(_:restoreUserInterfaceForPictureInPictureStopWithCompl etionHandler:)"
"pictureInPictureControllerWillStopPictureInPicture"
"pictureInPictureControllerDidStopPictureInPicture"
Run Code Online (Sandbox Code Playgroud)
点击关闭按钮时将跳过restoreUserInterface回调并直接进入
"pictureInPictureControllerWillStopPictureInPicture"
"pictureInPictureControllerDidStopPictureInPicture"
Run Code Online (Sandbox Code Playgroud)
因此,您可以使用 Bool 标志来检查 willStop/DidStop 是否调用了restoreUserInterface。
AVPictureInPictureViewController 中还有一个pictureInPictureSuspended属性,但我尝试检查它的值,发现在这两种情况下它总是返回 false,所以我必须使用上面的技巧来检查用户是否点击了恢复或关闭按钮。
| 归档时间: |
|
| 查看次数: |
1183 次 |
| 最近记录: |