Augustin A
Augustin A

Reputation: 127

MPMoviePlayerController rotation

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

Answers (2)

Sport
Sport

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

Granit
Granit

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

Related Questions