Putting a video to pause state before playing

帅比萌擦擦* 提交于 2019-11-29 05:17:00

You can hide your MPMoviePlayer until that annoying black flicker is gone.

To ensure that the black flicker is gone, you can check if the MPMoviePlayer's loadState is 3 ( which means MPMovieLoadStatePlayable | MPMovieLoadStatePlaythroughOK ) and playbackState is 1 (which means MPMoviePlaybackStatePlaying)

First hide your MPMoviePlayer:

yourMPMoviePlayer.view.hidden = YES;

Just add an observer to be notified when loadState changes:

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

And make your MPMoviePlayer visible again when you are notified and conditions are met:

-(void)loadStateChanged:(NSNotification *)sentNotification
{
    if ( player.loadState == 3 &&  player.playbackState == 1 )
       yourMPMoviePlayer.view.hidden = NO;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!