0

It seems the best (only?) way to rotate an MPMoviePlayerController to landscape is to use an MPMoviePlayerViewController .

I'm currently modifying an open source game which, unfortunately, does not have a root UIViewController set. Is there any way to set the orientation only with MPMoviePlayerController, or do I have to suck it up and hack a root UIViewController into this application?

Edit: in response to Shivan Raptor, the game is Canabalt: https://github.com/ericjohnson/canabalt-ios. I'm instantiating an MPMoviePlayerController as follows:

self.moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:self.videoTempFilePath];
self.moviePlayerController.repeatMode = MPMovieRepeatModeNone;

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlaybackComplete:)
                                             name:MPMoviePlayerDidExitFullscreenNotification
                                           object:self.moviePlayerController];
[glView addSubview:self.moviePlayerController.view];

// MUST SET THIS HERE AFTER WE ADD AS SUBVIEW
self.moviePlayerController.fullscreen = YES;

[self.moviePlayerController play];

The movie plays in portrait and stays locked there, but I'd like to play it in landscape.

Community
  • 1
  • 1
kevlar
  • 1,110
  • 3
  • 17
  • 30

2 Answers2

0

I think this might helpful.

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {

if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
    [self.view setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
    return true;
}
else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
    [self.view setTransform:CGAffineTransformMakeRotation(M_PI * 2)];
    return true;
}
else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
    [self.view setTransform:CGAffineTransformIdentity];
    return true;
}
else return false;
}
Deepak
  • 1,421
  • 1
  • 16
  • 20
0

I created a root UIViewController and made the MPMoviePlayerViewController a child of it. This created the desired effect.

kevlar
  • 1,110
  • 3
  • 17
  • 30