In an iOS5 application for iPhone 4/4s I have a UIViewController with an MPMoviePlayerController view added to its view:
[self.view insertSubview:self.fullscreenMoviePlayerController.view atIndex:2];
The UIViewController only supports landscape orientation:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation
{
// Return YES for supported orientations.
return interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}
this correctly locks rotation to only landscape. However when I set the MPVideoPlayerController to display fullscreen, this is ignored and the video is no longer constrained to landscape and rotates to whatever orientation the phone is held in.
How can I prevent MPMoviePlayerController's video from rotating to Portrait orientations in fullscreen? It is crucial that the video does not rotate when the phone is rotated to portrait.
I have tried subclassing MPVideoPlayerController and overriding shouldAutorotateToInterfaceOrientation:
but this has no effect.
The MPMoviePlayerController is only one part of the view, so using an MPMoviePlayerViewCotroller is absolutely not an option.