在播放之前将video暂停

我正在使用MVMoviePlayer在应用程序中播放video。 现在,点击播放button后,屏幕出现黑屏,video开始播放。 但是,从用户端的angular度来看,黑屏是一个令人头痛的问题。 所以,我想从暂停状态开始video。 为了做到这一点,我想在播放之前把播放器暂停。

有没有办法做到这一点???

你可以隐藏你的MPMoviePlayer直到那个恼人的黑色闪烁消失。

为了确保黑色闪烁消失,可以检查MPMoviePlayer是否为3(表示MPMovieLoadStatePlayable | MPMovieLoadStatePlaythroughOK ),playbackState是1(表示MPMoviePlaybackStatePlaying

首先隐藏你的MPMoviePlayer

 yourMPMoviePlayer.view.hidden = YES; 

只需添加一个观察者,以便在loadState更改时得到通知:

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loadStateChanged:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil]; 

当你得到通知并满足条件时,使你的MPMoviePlayer再次可见:

 -(void)loadStateChanged:(NSNotification *)sentNotification { if ( player.loadState == 3 && player.playbackState == 1 ) yourMPMoviePlayer.view.hidden = NO; }