I created an AVPlayerViewController and an attached AVPlayer in the viewDidAppear method of a custom UIViewController. Ho
You could do it by subclassing AVPLayerViewController. But there is some undefined behaviour due to this. (Given in Apple docs. See below) I also tried subclassing AVPlayerViewController and I faced Memory issue.
According to the Apple Docs:
Do not subclass AVPlayerViewController. Overriding this class’s methods is unsupported and results in undefined behavior.
Currently, they do not offer a callback when the AVPlayerViewController is dismissed. See Apple developer forum:
In thread1 Apple guy says:
I still believe that managing the exit of the AVPlayerViewController instance manually by utilizing the recommended gesture method above would be the most reliable way to know that the player view controller has been dismissed, since you'll be in charge of its dismissal at that point
Hope it helps!
Well, there is a fix to the problem. You can add a button as a subview of AVPlayerViewController. By doing so, you could intercept done button tap gesture.