AVPlayerViewController dismissed notification

Hi,

I'm presenting an AVPlayerViewController from another ViewController, I'd like to get a callback when the Done button is touched.

According to the documentation:

"Do not subclass

AVPlayerViewController
. Overriding this class’s methods is unsupported and results in undefined behavior."


So I cannot trigger a custom notification on ViewWillDisappear, I also tried with AVPlayerItemDidPlayToEndTimeNotification:


    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(playerItemDidReachEnd:)
                                                 name:AVPlayerItemDidPlayToEndTimeNotification
                                               object:videoPlayer.player];


I remember that on the now deprecated MPMoviePlayerController there was

MPMoviePlayerPlaybackDidFinishNotification for that.


Is there a way to get a callback from a generic presented view when it's dismissed ?

Or something more specific for AVPlayerViewController ?

Maybe KVO on something in the inner AVPlayer ?


Thanks

Accepted Reply

That is not currently possible. I would suggest filing an enhancement request at bugreporter.apple.com and provide some context as to why you require this notification.

Replies

Found another smiliar question here:

https://forums.developer.apple.com/thread/13715?q=AVPlayerViewController%20dis

Still no answer though.

That is not currently possible. I would suggest filing an enhancement request at bugreporter.apple.com and provide some context as to why you require this notification.

I just finaly filed this radar: 27047358

I need to intercept the done button press because I need to update some state information in the view controller that presented the AVPlayerViewController. I know, this is bad from an architecture point of view, but I need to do these hacks due to (other and even worse) limitations of the AVPlayerViewController such as (a) inability to show playback errors to the user and (b) lack of support for displaying timed metadata.

I think I’ll end up creating a custom player view controller as I don’t have any hope in Apple fixing AVKit any time soon: this is a known limitation since the AVPlayerViewController initial release!