I'm trying to know when an AVPlayerViewController was dismissed or exited full screen in order to change its parent view controller layout but I'm having no luck finding a delegate method that tells me when it happens.
I've tried adding an observer on the view controller like so:
player = AVPlayer(URL: NSURL(fileURLWithPath: videoPath))
playerController = AVPlayerViewController()
playerController?.delegate = self
playerController!.player = player
playerController?.contentOverlayView?.addObserver(self, forKeyPath: "bounds", options: NSKeyValueObservingOptions.New, context: nil)
addChildViewController(playerController!)
but it's never triggered.
I just want to know when playerController
is being dismissed or user exited full screen.
答案 0 :(得分:0)
您可以在父视图控制器的viewWillAppear:
方法中处理它。
func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if let playerController = playerController {
// handle exit of playerController here...
}
}
答案 1 :(得分:-4)
如果您希望跟踪用户退出全屏或视频状态,您可以使用MPMoviePlayerController。