Make MPMoviePlayerController play the landscape

I am new to iPhone development and am writing my first app. The entire application needs only portrait mode, with the exception of video playback. I use MPMoviePlayerController to run the movie and it plays in protrait mode. How to get MPMoviePlayerController to play all movies in Landscape. I am using Xcode 4 and am creating for iOS 4.0+. Do I need to enter some settings in info.plist so that MPMoviePlayerController can play in the landscape?

Here is the code I'm using to initialize MPMoviePlayerController:

MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL: url]; [self.view addSubview:theMovie.view]; theMovie.allowsAirPlay=YES; [theMovie setFullscreen:YES animated:YES]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie]; [theMovie play]; 
+4
source share
2 answers

Insert the player into your own view controller and execute shouldAutorotateToInterfaceOrientation as follows:

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { return UIInterfaceOrientationIsLandscape(toInterfaceOrientation); } 
+6
source

Subclass the MPMoviePlayerViewController class:

@interface MyMoviePlayerViewController ()

@end

 @implementation MyMoviePlayerViewController - (BOOL)shouldAutorotate { return NO; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } @end 
0
source

All Articles