Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 8 MPMoviePlayerPlaybackDidFinishNotification not working

I used Xcode 6 with iOS 8 SDK.

If the video can't played, when starting MPMoviePlayer. MPMoviePlayerPlaybackDidFinishNotification not working.

I reference this article: [How to get an error description when playback fails on MPMoviePlayerController but iOS8 doesn't work.

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

How to do that can solve this problem? Thanks.

like image 780
OPUS Avatar asked Sep 22 '14 19:09

OPUS


2 Answers

I had same issue and the only solution I found was to replace the MPMoviePlayerController by a AVPlayerViewController (available since iOS 8 in the AVKit framework).

like image 104
pgeof Avatar answered Oct 16 '22 05:10

pgeof


Make sure the "object" parameter is of class MPMoviePlayerController and not MPMoviePlayerViewController.

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

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

to this:

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

The object sending the notification is self.MoviePlayer.moviePlayer

like image 42
Shaked Sayag Avatar answered Oct 16 '22 04:10

Shaked Sayag