Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Had the same problem, just spent half a day sorting it out. With the iPad in portrait orientation, whenever I started a video using the sample code (or any I could find on the net) the video and control bar were formatted for portrait, and hence all over the place on the screen.</p> <p>Anyway, the following works for me. </p> <pre><code> /* Call the code like below: int iLandscape; if( newOrientation==UIInterfaceOrientationLandscapeLeft || newOrientation==UIInterfaceOrientationLandscapeRight ) iLandscape=1; [self PlayVideo:iLandscape fullscreen:1] */ ////////////////////////////////////////////////////////////////////////// - (void)PlayVideo:(int)iLandscape fullscreen:(int)iFullScreen { NSString *url = [[NSBundle mainBundle] pathForResource:@"myvideofile" ofType:@"m4v"]; if( iFullScreen==0 ) { MPMoviePlayerController *player2 = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:player2]; //---play partial screen--- player2.view.frame = CGRectMake(0, 0, m_iScreenWidth, m_iScreenHeight); [self addSubview:player2.view]; //---play movie--- [player2 play]; } else { MPMoviePlayerViewController *playerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:url]]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:[playerViewController moviePlayer]]; if( iLandscape ) { playerViewController.view.frame = CGRectMake(0, 0, m_iScreenWidth, m_iScreenHeight); } [self addSubview:playerViewController.view]; //play movie MPMoviePlayerController *player = [playerViewController moviePlayer]; player.scalingMode=MPMovieScalingModeAspectFit; [player play]; } } ////////////////////////////////////////////////////////////////////////// - (void) movieFinishedCallback:(NSNotification*) aNotification { MPMoviePlayerController *player = [aNotification object]; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player]; [player autorelease]; [player.view removeFromSuperview]; } </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