IOS 8 MPMoviePlayerPlaybackDidFinishNotification not working

I used Xcode 6 with iOS 8 SDK.

If the video does not play, start MPMoviePlayer. MPMoviePlayerPlaybackDidFinishNotification does not work.

I refer to this article: [ How to get a description of the error when MPMoviePlayerController fails to play, but iOS8 does not work.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MPFinished: ) name:MPMoviePlayerPlaybackDidFinishNotification object:self.MoviePlayer]; 

How to do this can solve this problem? Thanks.

+6
source share
2 answers

I had the same problem and the only solution I found was to replace MPMoviePlayerController with AVPlayerViewController (available from iOS 8 as part of AVKit).

+2
source

Verify that the object parameter belongs to the MPMoviePlayerController class, not the MPMoviePlayerViewController.

If self.MoviePlayer is an MPMoviePlayerViewController, just change this:

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MPFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.MoviePlayer]; 

:

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MPFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.MoviePlayer.moviePlayer]; 

The object sending the notification is self.MoviePlayer.moviePlayer

+1
source

Source: https://habr.com/ru/post/975680/


All Articles