How to stop MPMoviePlayerViewController's automatic dismiss on moviePlaybackDidFinish?

An MPMoviePlayerViewController which is presented modally through presentMoviePlayerViewControllerAnimated: automatically dismisses itself when it’s content finishes playing.

I’ve tried to disable this, since I want to play other content afterwards. However, even if I register to the NSNotificationCenter with [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:playerVC.moviePlayer]; and set some other content, it still dismisses.

  • Passing multiple tags with UIButton
  • iPhone Could Not Support Development
  • iOS - Flip animation only for specific view
  • UIButton Changing Position
  • Adding vCard data directly to the system Address Book
  • Detect single tap in UIWebView, but still support text selection and links
  • How can I stop MPMoviePlayerViewController from automatically dismissing itself?


    As a clarification, this question is only about removing the automatic dismissal and not about dealing with the disabled ‘done’ button. The selected answer reflects. This is by design, since we assume the developer adds their own means of dismissing the MPMoviePlayerViewController. However, @bickster‘s answer deals with the ‘done’ button as well.

    4 Solutions Collect From Internet About “How to stop MPMoviePlayerViewController's automatic dismiss on moviePlaybackDidFinish?”

    Thanks to this blog article I figured out that MPMoviePlayerViewController automatically registers itself to the NSNotificationCenter upon creation. You have to first remove this registration and it will stop dismissing itself automatically.

    // Initialize the movie player view controller with a video URL string
    MPMoviePlayerViewController *playerVC = [[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:aVideoUrl]] autorelease];
    // Remove the movie player view controller from the "playback did finish" notification observers
    [[NSNotificationCenter defaultCenter] removeObserver:playerVC  name:MPMoviePlayerPlaybackDidFinishNotification object:playerVC.moviePlayer];

    You can use this code to stop the viewcontroller from automatically dismissing and capture the event when the user clicks the “Done” button so you can dismiss the viewcontroller yourself.

    Step 1. – alloc a MPMoviePlayerViewController

    videoPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[[NSURL alloc ]initWithString:[aURL];

    Step 2. – Remove the default MPMoviePlayerPlaybackDidFinishNotification observer and add your own

    [[NSNotificationCenter defaultCenter] removeObserver:videoPlayer
    name:MPMoviePlayerPlaybackDidFinishNotification object:videoPlayer.moviePlayer];
    [[NSNotificationCenter defaultCenter] addObserver:self
    selector:@selector(videoFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:videoPlayer.moviePlayer];

    Step 3. – Present viewcontroler

    [self presentMoviePlayerViewControllerAnimated:videoPlayer];

    Step 4. – Add videoFinish: method

        int value = [[aNotification.userInfo valueForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue];
        if (value == MPMovieFinishReasonUserExited) {
            [self dismissMoviePlayerViewControllerAnimated];

    You can try something like this.

    when the mpmovieplayercontroller finishes playing a video and you recieve the notification in your method movieFinishedCallback: implemect

           [playerVC.movieplayer setContentURL:// set the url of the file you want to play here];
           [playerVC.moviePlayer play];

    Hope this helps

    Since “Done” button is not working anymore if I remove MPMoviePlayerPlaybackDidFinishNotification from NSNotificationCenter, I change repeat mode to MPMovieRepeatModeOne.
    Then, everything’s working fine except the video is repeated.

    MPMoviePlayerViewController *playerVC = [[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:aVideoUrl]] autorelease];
    [playerVC.moviePlayer setRepeatMode:MPMovieRepeatModeOne];