I start a MPMoviePlayerController in fullscreen mode, and then close it with the default buttons. It works like a charm on iOS4.3 but leaves a black screen on iOS5.0 :(
Am I doing something wrong? here is my code:
To show the player:
- (void)showVideo {
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theURL];
// Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
moviePlayer.shouldAutoplay = YES;
moviePlayer.view.frame = [[UIScreen mainScreen] applicationFrame];
moviePlayer.view.transform = CGAffineTransformMakeRotation(1.57079633);
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:NO];
}
To close the player:
- (void) moviePlayBackDidFinish : (NSNotification *) notification
{
MPMoviePlayerController *moviePlayer = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
[moviePlayer.view removeFromSuperview];
[moviePlayer stop];
[moviePlayer release];
//otherwise the status bar hides or changes color from time to time
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:NO];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}
I've been trying to solve the same problem after updating to iOS5.