Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here are how the events -> notifications work:</p> <ul> <li><p><strong>User presses 'Done' button</strong> </p> <ul> <li><code>MPMoviePlayerWillExitFullscreenNotification</code></li> <li><code>MPMoviePlayerDidExitFullscreenNotification</code></li> </ul></li> <li><p><strong>User presses 'Leave fullscreen' button on transport</strong></p> <ul> <li><code>MPMoviePlayerWillExitFullscreenNotification</code></li> <li><code>MPMoviePlayerDidExitFullscreenNotification</code></li> <li>Note that <em>playback does not stop</em></li> </ul></li> <li><p><strong>Movie reaches end</strong></p> <ul> <li><code>MPMoviePlayerPlaybackDidFinishNotification</code> with the <code>MPMoviePlayerPlaybackDidFinishReasonUserInfoKey</code> set to <code>MPMovieFinishReasonPlaybackEnded</code></li> <li>If you call <code>setFullscreen:NO animated:YES</code> on your MoviePlayerController instance from this notification, you'll then get the <code>WillExit</code> and <code>DidExit</code> notifications.</li> <li>Note that you don't get the <code>PlaybackDidFinish</code> notification when the user presses the Done or Leave Fullscreen buttons.</li> </ul></li> </ul> <p>So, typically, if you want to get rid of the MoviePlayer's view, you need to put <code>[self.moviePlayerController.view removeFromSuperview]</code> in the <code>DidExitFullscreen</code> notification handler. <code>WillExitFullscreen</code> is too soon.</p> <p>Here's my code:</p> <pre><code>- (void)willEnterFullscreen:(NSNotification*)notification { NSLog(@"willEnterFullscreen"); } - (void)enteredFullscreen:(NSNotification*)notification { NSLog(@"enteredFullscreen"); } - (void)willExitFullscreen:(NSNotification*)notification { NSLog(@"willExitFullscreen"); } - (void)exitedFullscreen:(NSNotification*)notification { NSLog(@"exitedFullscreen"); [self.movieController.view removeFromSuperview]; self.movieController = nil; [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (void)playbackFinished:(NSNotification*)notification { NSNumber* reason = [[notification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey]; switch ([reason intValue]) { case MPMovieFinishReasonPlaybackEnded: NSLog(@"playbackFinished. Reason: Playback Ended"); break; case MPMovieFinishReasonPlaybackError: NSLog(@"playbackFinished. Reason: Playback Error"); break; case MPMovieFinishReasonUserExited: NSLog(@"playbackFinished. Reason: User Exited"); break; default: break; } [self.movieController setFullscreen:NO animated:YES]; } - (void)showMovie { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willEnterFullscreen:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willExitFullscreen:) name:MPMoviePlayerWillExitFullscreenNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enteredFullscreen:) name:MPMoviePlayerDidEnterFullscreenNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitedFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; NSURL* movieURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"tron" ofType:@"mov"]]; self.movieController = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; self.movieController.view.frame = self.view.frame; [self.view addSubview:movieController.view]; [self.movieController setFullscreen:YES animated:YES]; [self.movieController play]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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