Question

My iPad app displays a movie full screen using the convenient MPMoviePlayerViewController class. I present it like this:

 [self.hostController presentMoviePlayerViewControllerAnimated:playerViewController];

And later, when notified that playing is done, I dismiss it like this:

 [self.hostController dismissMoviePlayerViewControllerAnimated];

It works fine, except when the user rotates the iPad during movie playback:

1- The iPad is in vertical orientation. My view is vertical. 2- The user starts the movie in vertical orientation. The player is vertical. 3- The user rotates the iPad to the horizontal orientation. 4- The player switches to its horizontal orientation. so far so good. 5- The movie stops, the player is dismissed, my reappears, the iPad is still horizontal, but my view has stayed in the vertical orientation is was in step 1. Now it looks sideways.

Of course, if the user then rotates the iPad, it's back to normal. My view then rotates normally as the iPad rotates.

Did anyone ever encounter that? An easy fix?

Thanks.

Was it helpful?

Solution

I've encountered this numerous times and it appears to be an Apple bug (and have reported it as such).

The only way (I've found) around this is to listen to UIDeviceOrientationDidChangeNotification and UIApplicationDidChangeStatusBarOrientationNotification notifications. Use the relative timestamp on these notifications; if they both occur within a second of each other, you can be sure that the status bar change is a result of the user switching orientations and not the media SDK changing the status bar orientation. Then, when the movie is finished, you can tell your view controller that it should rotate to landscape.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top