Abdullah Shafique Abdullah Shafique - 1 year ago 138
iOS Question

MPMoviePlayerViewController Enable Landscape Mode

I am adding an MPMoviePlayerViewController to my app like this:

MPMoviePlayerViewController *vc = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];;
[self presentMoviePlayerViewControllerAnimated:vc];

Everything is working but I can't enable landscape mode. I want my whole app except the actual MPMoviePlayerViewController to be portrait. I searched on google but all the solutions require having the rest of the app also in landscape.I need my app to stay in Portrait except in the MPMoviePlayerViewController.

Thanks in advance!


Using @matt answer I added landscape to my Device Orientation:

enter image description here

Next I went to my First View Controller(Not the MPMoviePlayerViewController) and added:

return UIInterfaceOrientationMaskPortrait;

However the app still let's the Main Menu go to Landscape mode.

Answer Source

Actually there is a way to just make Movie Player landscape without affecting portrait view of rest of screens.

#define degreesToRadian(x) (M_PI * (x) / 180.0)

MPMoviePlayerViewController *moviePlayerVC = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:@"http://someurl.com"]];

moviePlayerVC.view.transform = CGAffineTransformIdentity;
moviePlayerVC.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));

[self presentViewController:moviePlayerVC animated:NO completion:NULL];

Make sure you are using MPMoviePlayerViewController and not MPMoviePlayerController, else it won't work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download