gpt4 book ai didi

iphone - MPMoviePlayerController 在 iOS5.0 上未关闭

转载 作者:行者123 更新时间:2023-12-03 20:28:17 25 4
gpt4 key购买 nike

我以全屏模式启动 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];
}

最佳答案

更新到 iOS5 后我一直在尝试解决同样的问题。

  • 这是我目前想到的:

It's a bug in the MPMoviePlayerController after going into fullscreen mode. Basically you can't leave the fullscreen mode. But this should be solved if we just remove the MPMoviePlayerController. But no luck there...

Could it be that the main view doesn't start redrawing after going to full screen with the video player? (Pausing redrawing of the views under de fullscreen should improve performance of video playback. And as far as I know this should be the case.)

  • 这是一个解决方案:(tkx 去我的大学,谁有最初的问题)

Don't go into fullscreen mode and just stretch the MPMoviePlayerController to the parent views bounds. The problem here is that if we rotate our screen the automatic rotation that the fullscreen mode gave is doesn't get used.

//instead of going to fullscreen
//[moviePlayer setFullscreen:YES animated:YES];
[moviePlayer.view setFrame:self.view.bounds];

//when the movie has finished playing release it
  • 旋转问题的解决方案:

Write rotation code :)

关于iphone - MPMoviePlayerController 在 iOS5.0 上未关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7795179/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com