影片播放還不錯,但在播放之前會有一個快速黑色閃光。這是由於將controlstyle設置爲MPMovieControlStyleNone而導致的一個怪癖嗎?MPMoviePlayerController在視頻開始時會導致黑屏閃爍
NSString *url = [[NSBundle mainBundle] pathForResource:@"00" ofType:@"mov"];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc]
initWithContentURL:[NSURL fileURLWithPath:url]];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
//---play video in implicit size---
player.view.frame = CGRectMake(80, 64, 163, 246);
[self.view addSubview:player.view];
// Hide video controls
player.controlStyle = MPMovieControlStyleNone;
//---play movie---
[player play];
我也有這個問題。但是這個解決方案很棘手,因爲你不知道MPMovilePlayerController需要渲染視頻的時間。所以它肯定會隱藏黑色閃光,但也是視頻的開始。 更好的答案:http://stackoverflow.com/a/28079496/2327367 – LastMove 2015-09-09 10:34:53