I've done this to get Done
button click event from AVPlayerViewController
.
First of all, Create an extension of Notification.Name
like bellow
extension Notification.Name {
static let kAVPlayerViewControllerDismissingNotification = Notification.Name.init("dismissing")
}
Now, Create an extension of AVPlayerViewController
and override viewWillDisappear
like bellow
// create an extension of AVPlayerViewController
extension AVPlayerViewController {
// override 'viewWillDisappear'
open override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// now, check that this ViewController is dismissing
if self.isBeingDismissed == false {
return
}
// and then , post a simple notification and observe & handle it, where & when you need to.....
NotificationCenter.default.post(name: .kAVPlayerViewControllerDismissingNotification, object: nil)
}
}
THIS IS FOR ONLY BASIC FUNCTIONALITY THAT HANDLES DONE BUTTON'S EVENT.
happy coding...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…