How to play landscape video using MPMovieViewController in portrait-only application

My application supports the orientation of the interface: "Portrait" and "upside down." However, when a video is playing, I want it to play full screen. Currently, with this code, it only reproduces a portrait, even when the device is rotated:

[player.moviePlayer setControlStyle:MPMovieControlStyleFullscreen]; player.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; [self presentMoviePlayerViewControllerAnimated:player]; 

How can I get it in landscape mode?

+6
source share
1 answer

Here is how I do it:
In the project file, make sure you support landscape orientation supported interface orientations
Now in all your ViewControllers, which should still only be portrait, add this code

 //ios6 - (BOOL)shouldAutorotate { return NO; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } //ios4 and ios5 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } 

I turned on both iOS5 and iOS6 calls so that my code works on both.

When your MPMoviePlayerController view becomes full-screen, it will be the new ViewController located on top of everything else. Thus, he will be allowed to rotate in accordance with the Orientations of the supported project interface. He will not see where you got the other ViewControllers in Portrait.

+11
source

All Articles