In iOS 9 MPMoviePlayer and all his components are deprecated.
We used MPMoviePlayerController notifications, like MPMoviePlayerLoadStateDidChangeNotification, MPMovieDurationAvailableNotification, MPMoviePlayerPlaybackStateDidChangeNotification, MPMoviePlayerReadyForDisplayDidChangeNotification
, to track video service quality. But now with AVPlayerViewController I can't find properly replacement for these notifications.
How do I replace these notifications now?
AVPlayerViewController
is a lot different in its usage from theMPMoviePlayerViewController
. Instead of using notifications you use Key Value Observing to determine the current characteristics of theAVPlayer
object associated with theAVPlayerViewController
. According to the docs:For instance, if you want to know when your player has been paused add an observer on the
rate
property of theAVPlayer
object:Then in the observe method check if the
new
value is equal to zero:A lot of properties on the
AVPlayer
are observable. Go through the Class reference.Also apart from this there are several Notifications available for the
AVPlayerItem
object which are limited but still helpful.I find
AVPlayerItemDidPlayToEndTimeNotification
particularly useful to seek the Item to the start once playback has finished.Using these two options together you should be able to replace most if not all notifications for the
MPMoviePlayerController
I looked at the documentation for both
MPMoviePlayerNotifications
andAVPlayerItemNotifications
and I notice two things.MPMoviePlayerNotifications
don't show they were deprecated:AVPlayerItemNotifications
don't have any replacements that I could see:So, I am confused that you are saying
MPMoviePlayerNotifications
are deprecated, because the docs are saying they are available. Also, I don't thinkAVPlayerItemNotifications
has a replacement forMPMoviePlayerNotifications
.