我以全屏模式启动 MPMoviePlayerController,然后使用默认按钮将其关闭。它在 iOS4.3 上就像一个魅力,但在 iOS5.0 上留下黑屏:(
难道我做错了什么?这是我的代码:
向玩家展示:
- (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];
}
关闭播放器:
- (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];
}