How do I intercept tapping of the done button in AVPlayerViewController?

前端 未结 10 732
渐次进展
渐次进展 2021-01-03 22:45

I created an AVPlayerViewController and an attached AVPlayer in the viewDidAppear method of a custom UIViewController. Ho

10条回答
  •  渐次进展
    2021-01-03 23:17

    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:

    • Thread1
    • Thread2

    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.

提交回复
热议问题