I have an app whose rotation configuration is defined dynamically, therefore I cannot set the supported rotations in the project file.
Therefore I have to handle the new shouldRotate methods (thanks Apple!!)
But despite having overriden these and prevented the full UI from displaying in anything but portrait. When a video view is displayed fullscreen and rotated. The video will rotate to landscape still.
Is there another way to preview the video specifically from rotating at all?
Here's an implementation using a MPMoviePlayerViewController
subclass supporting portrait and portrait upside down (but you can easily change the mask). This works in iOS 6 as you suggested, prior versions have different rotation selectors.
Usage:
NSURL* url = [NSURL URLWithString:@"your_movie"];
MovieViewController* mvc = [[MovieViewController alloc] initWithContentURL:url];
// I did this from the app delegate.
// You could push this view controller, present it modally, etc.
[self.window setRootViewController:mvc];
In MovieViewController.h:
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface MovieViewController : MPMoviePlayerViewController
- (id)initWithContentURL: (NSURL*) url;
@end
In MovieViewController.m:
#import "MovieViewController.h"
#import <MediaPlayer/MediaPlayer.h>
@interface MovieViewController ()
@end
@implementation MovieViewController
- (id)initWithContentURL: (NSURL*) url
{
self = [super initWithContentURL: url];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
ROTATION CODE
*/
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
@end
Result (note rotation is enabled on the project for all rotations..):