You've added an
MPMoviePlayerController to one of your view controller's
child views. You hit play, it starts playing the video. Then you hit the
fullscreen button. It fills the screen, and suddenly everything goes black, you
can't get any controls, and all that happens is the audio keeps playing.
So what went wrong?
So my best guess is that the view that contains the
view is a temporary one in your view controller. Something that you get rid of
when the view controller's view stops being displayed. So what you decided was
to remove the view from the view controller (
removeFromSuperview) when the
view controller is no long displayed.
The obvious place to do that is in
viewWillDisappear:, right? It
consolidates all these actions into one place, and happens automatically.
The problem? When the movie goes fullscreen, your view disappears and
viewWillDisappear: is called. MPMovePlayerController doesn't work well
when its view gets removed from the view hierarchy. Whoops.
I solved this by moving my view destroying code into a new method and out of
viewWillDisappear:. In my case all the times I wanted the view to be removed
are times when I'm triggering
viewWillDisappear: manually with a call to
pushViewController:animated: to the
navigationController. So right
above that call, I added a call to my new method.
If you have situations where you don't control the transition that causes your
view to be destroyed, you might want to add a
BOOL to safegaurd the view from
being destroyed if video playback is happening.
You might run into this problem transitioning from iOS 5 to iOS 6. Apple fixed a bug where
viewWillDisappear:wasn't being called for the fullscreen transition. So this doesn't happen in iOS 5, but does in iOS 6. ↩︎