My app is quite simple, with a UINavigationController as the root view controller which displays a main navigation screen, and a few detail screens. The main screen does not support rotation due to layout constraints, and for consistency the detail screens (which are simply pushed onto the navcontroller's stack) don't either. However, some of the detail screens contain links to videos, and the videos need to display in portrait mode. The app displays the player modally using MPMoviePlayerController.
I just had a similar issue, and tried the solution above which applies an affine transform to the MPMoviePlayerController's view, but the problem was that the status bar continued to display as in portrait mode, and overlapped the modal movie player view (on the left, if viewed in according to the rotation above). I tried a couple of things to no avail:
Hiding the status bar. This didn't work, because the player exists in its own world, and goes ahead and presents the status bar anyway. I couldn't find a way to make this go away.
Explicitly setting the status bar orientation. I'm not sure exactly why this didn't work, but I suspect that it was because I'd indicated in my info.plist that only portrait was supported and was therefore cut off from making changes.
Net-net, the above didn't work for me. Just as well, b/c Apple admonishes devs to treat the MPMoviePlayerController as opaque, and (especially with the transform method) I was violating this.
In the end, I found a simpler solution that worked for me:
In the info.plist, I indicated that all orientations (except for upside down, so the standard iPhone idiom) were supported.
Subclass UINavigationController, and override the appropriate shouldAutorotate methods so that only Portrait is supported (see this solution, among others, for how to do this in iOS <6 and iOS6 concurrently).
This worked because:
While I'd indicated that autorotation is supported by the app, I cut it off at the UINavigationController subclass which contains all of the views I'm rendering... so everything remains portrait, except for:
The MPMoviePlayerController is being presented modally, atop the NavigationController, and lives in its own world. Therefore it's free to pay attention to what's in the info.plist, and rotate all by itself.
There are a bunch of examples for how to present the player modally, but for quick reference, here's my code:
- (void)presentModalMediaPlayerForURL:(NSURL *)inURL
{
NSLog(@"Will play URL [%@]", [inURL description]);
MPMoviePlayerViewController *player = [[MPMoviePlayerViewController alloc] initWithContentURL:inURL];
[player.view setBounds:self.view.bounds];
[player.moviePlayer prepareToPlay];
[player.moviePlayer setFullscreen:YES animated:YES];
[player.moviePlayer setShouldAutoplay:YES];
[player.moviePlayer setMovieSourceType:MPMovieSourceTypeFile];
[self presentModalViewController:player animated:YES];
[player release];
}