Search code examples
iphoneorientationmpmovieplayercontrollerfullscreenlandscape

How can I start a movie in full screen mode OR re-adjust the player width when I go landscape?


I have a very simple move view that upon loading, jumps right into a video. The movie controls show up great and everything. But I get a problem when I rotate to landscape, the movie player width doesn't adjust with the view, so it remains too narrow.

If I'm in the full screen mode, where my nav bar goes away and stuff, I can rotate and it works no problem.

So how can I either adjust the width of the viewer when I switch to landscape, OR just start the view in the fullscreen mode?

Note: [mpPlay setFullscreen:YES]; isn't doing it for me.

Here is the rest of my code:

- (void)viewDidLoad 
{
NSBundle * bundle = [NSBundle mainBundle];
NSString * moviePath = [bundle pathForResource:@"movie" ofType:@"mp4"];
NSURL * movieURL = [[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController * mpPlay = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

[mpPlay.view setFrame: self.view.bounds];  // player's frame must match parent's
[self.view addSubview: mpPlay.view];

[mpPlay play];

 }

Solution

  • Override didRotateFromInterfaceOrientation: in your view controller and change the movie player to the new width and height.