Reputation: 127
How to rotate the video player in iOS programming using MPMoviePlayerController
.
My code:
moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen = YES;
[moviePlayerController play];
Upvotes: 0
Views: 349
Reputation: 8985
try this
-(void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ChangedmyMPMoviePlayerController :) name:UIDeviceOrientationDidChangeNotification object:nil];
}
-(void) ChangedmyMPMoviePlayerController:(NSNotification *)notification
{
[self adjustMPMoviePlayerController:[[UIApplication sharedApplication] statusBarOrientation]];
}
- (void) adjustMPMoviePlayerControlle:(UIInterfaceOrientation) orientation {
if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
{
[self.moviePlayerController setFullscreen:NO animated:YES];
}
else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
[self.moviePlayerController setFullscreen:YES animated:YES];
}}
Upvotes: 0
Reputation: 1281
Try changing the bounds and rotating the view like this:
[[moviePlayer view] setBounds:CGRectMake(20, 0, 480, 350)];
[[moviePlayer view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
playerControlsContainer.hidden = YES;
Upvotes: 1