Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPad rotation bug when using MPMoviePlayerViewController

Issue summary

Changing the orientation of an iPad device or simulator while playing a video using MPMoviePlayerViewController results in an inconsistent rotation state upon dismissal of the video player. This is a known bug in iPad SDK 3.2, documented at http://www.openradar.me/8012810

Sample project

I have prepared a minimal sample project using the View-based Application template from Xcode 3.2.2, using the following code to launch the player

NSURL *movieUrl = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
MPMoviePlayerViewController *player = [[MPMoviePlayerViewController alloc] initWithContentURL:movieUrl];
[self presentMoviePlayerViewControllerAnimated:player];
[player release];

The code is available on GitHub at http://github.com/adamalex/FullScreenMovie or direct download using http://github.com/adamalex/FullScreenMovie/zipball/master

Steps to reproduce

  1. Obtain the project using the information above
  2. Launch the project with the iPad simulator or device
  3. Tap the button to begin playing the video
  4. Rotate the iPad by 90 degrees
  5. Dismiss the video
  6. Note the UIStatusBar is out of sync with the application UI

Objective

I have contacted Apple and they have confirmed this is a bug that is being investigated. I would like to discuss temporary workarounds that use public APIs safe for submission to the App Store. I am going to open a developer support case with Apple as well and will report back with my own progress.

like image 962
Adam Alexander Avatar asked Jun 22 '10 01:06

Adam Alexander


1 Answers

Successful response from Apple Developer Technical Support!

This is a known bug and a we're received a number of duplicate bug reports and so iOS engineering is aware of the issue and we do have a temporary workaround as suggested by iOS engineering.

You will need to implement this in the view controller which presents the movie player.

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
   [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
   [self performSelector:@selector(fixStatusBar) withObject:nil afterDelay:0];
}

- (void)fixStatusBar {
   [[UIApplication sharedApplication] setStatusBarOrientation:[self interfaceOrientation] animated:NO];
}

While this is somewhat ugly, it should fix the issue for now. It would be recommended to remove this code once the bug is fixed in the system.

This took care of the issue completely for me, and you can revisit http://github.com/adamalex/FullScreenMovie for the code with the fix applied.

like image 108
Adam Alexander Avatar answered Sep 26 '22 01:09

Adam Alexander