0

I display a video using MPMoviePlayerViewController in a tabbar application, the video plays fine in portrait mode but doesn't rotate in landscape mode.

The same code works fine in another project without the tabbar.

I tried to force the autoresizingmask to flexibleWidth and flexibleHeight without success.

If i return YES in the shouldAutorotateToInterfaceOrientation the status bar rotates but not the movie interface.

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return YES;
}

    -(IBAction) showFamilleMovie {
     NSString *videoURL = [[NSBundle mainBundle] 
            pathForResource:@"film1" 
            ofType:@"mp4"];

     MPMoviePlayerViewController* theMoviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:videoURL]];
        theMoviePlayer.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
     [self presentMoviePlayerViewControllerAnimated:theMoviePlayer];

    }

Do you have any idea where the project could come from ?

Thanks, Vincent

vdaubry
  • 11,369
  • 7
  • 54
  • 76

2 Answers2

1

you can try:

 [yourTabbarController presentModalViewController: theMoviePlayer]

that should allow MoviePlayer to rotate.

Deniz Mert Edincik
  • 4,336
  • 22
  • 24
  • But i just realized the problem might be coming from the fact that i am already in a modal view ? – vdaubry Oct 24 '10 at 13:04
  • actually tabbar requires all children to respond, same answer to shouldAutorotateToInterfaceOrientation. Otherwise it does not support autorotation at all. By presenting video model, we are detaching it from tabbar, so it can rotate freely. – Deniz Mert Edincik Oct 24 '10 at 13:09
  • I tried to add shouldAutorotateToInterfaceOrientation to all the controller inside the tabbar. They all rotate to landscape but when i try to present the movie as a modal viw, only the status bar rotate (!). Do you you think it could come from the fact that the tabbar is already a modal view itself ? – vdaubry Oct 24 '10 at 13:15
  • I am not sure about it really, but it is highly possible. – Deniz Mert Edincik Oct 24 '10 at 13:23
1

I had the same problem and the code killer for that was a view added in my appDelegate code. It didn't let the player to rotate properly.

My problem was: To implement the FBConnect library, you need to add a view in your appDelegate to get the object for the FB controller class that you're using the handleOpenURL method (back from Safari when auth is done) and control the callback. I spent an hour until I realized that this view was blocking the rotation.

BTW, don't care about the tab bar. The player should rotate correctly even if you don't have the shouldAutorotateToInterfaceOrientation method added.

Marvin Pinto
  • 30,138
  • 7
  • 37
  • 54
Gorka
  • 31
  • 5