Created
March 25, 2014 20:17
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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