Skip to content

Instantly share code, notes, and snippets.

@paztek
Created March 25, 2014 20:17
Show Gist options
  • Save paztek/9770445 to your computer and use it in GitHub Desktop.
Save paztek/9770445 to your computer and use it in GitHub Desktop.
Allows videos to rotate in landscape when displayed in a portrait only iOS app
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// We configure the video player to play a remote video
NSURL *movieURL = [NSURL URLWithString:@"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"];
[self.movieController setContentURL:movieURL];
// We embed the video player inside the placeholder view
[self.movieController.view setFrame:self.videoContainerView.frame];
[self.movieController prepareToPlay];
[self.movieController setShouldAutoplay:NO];
[self.view addSubview:self.movieController.view];
}
- (MPMoviePlayerController *)movieController
{
if (_movieController == nil) {
_movieController = [[MPMoviePlayerController alloc]init];
}
return _movieController;
}
- (BOOL)shouldAutomaticallyForwardRotationMethods
{
return NO; // This way, we let the movie controller handle rotations itself
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment