Note that there are some explanatory texts on larger screens.

plurals
  1. POIphone mpmediaplayerController, unable to restart video after user presses done
    text
    copied!<p>I'm having trouble with Iphone's mediaplayercontroller.</p> <p>I'm able to play the video once, with no problems.</p> <p>When the user presses done, I close the mediaplayer, and move my user back to the previous screen. (I'm using a navigation based application).</p> <p>However, when I try to start the video again by pressing the play button, the mediaplayercontroller no longer works correctly.</p> <p>All I get is a black screen. No video, no sounds.</p> <p>I've already released the previous mediaplayper controller after getting the MPMoviePlayerPlaybackDidFinishNotification or the MPMoviePlayerDidExitFullscreenNotification.</p> <p>Any advice would be greatly appreciated.</p> <p>More Info------- Here is a snippet of my code:</p> <pre><code>- (void) viewDidAppear:(BOOL)animated { moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:url]; [self.view addSubview:moviePlayerController.view]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackComplete:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackComplete:) name:MPMoviePlayerDidExitFullscreenNotification object:nil]; // This is to deal with the user pressing the done button. [moviePlayerController setFullscreen:YES]; [moviePlayerController play]; } - (void)moviePlaybackComplete:(NSNotification *)notification { NSLog(@"movie playback ended"); int reason = [[[notification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue]; if(reason == MPMovieFinishReasonPlaybackEnded) NSLog(@"Reason: MPMovieFinishReasonPlaybackEnded"); else if(reason == MPMovieFinishReasonPlaybackError) NSLog(@"Reason: MPMovieFinishReasonPlaybackError"); else if(reason == MPMovieFinishReasonUserExited) NSLog(@"Reason: MPMovieFinishReasonUserExited"); else NSLog(@"Reason: %d", reason); [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerDidExitFullscreenNotification object:nil]; [moviePlayerController.view removeFromSuperview]; moviePlayerController.initialPlaybackTime = -1; [moviePlayerController pause]; [moviePlayerController stop]; [moviePlayerController release]; moviePlayerController = nil; [[self navigationController] popViewControllerAnimated:YES]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload