(ios)MPMoviePlayerController首次播放视频的时候,没有控制条

问题:

在视频播放时,现在控制条采用磨砂的效果,会遮罩部分视频

解决思路

1 播放器直接设置不带控制条,在app在 Foreground状态,默认播放器暂停,这样需要在获得Foreground事件,进行设置播放

- (void) viewWillAppear:(BOOL)animated{

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillEnterForegroundNotification) name:UIApplicationWillEnterForegroundNotification object:nil];

}

- (void) appWillEnterForegroundNotification{

NSLog(@"trigger event when will enter foreground.");

}

-(void) viewDidDisappear:(BOOL)animated{

[[NSNotificationCenter defaultCenter] removeObserver:self];

}

2 直接侦听播放器准备播放通知,在通知中设置播放器带控制条

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:)

name:MPMoviePlayerReadyForDisplayDidChangeNotification

object:player];

- (void) moviePlayBackDidFinish:(NSNotification*)notification

{

player.controlStyle =MPMovieControlStyleEmbedded;

[[NSNotificationCenter defaultCenter]removeObserver:self name:MPMoviePlayerReadyForDisplayDidChangeNotification object:player];

}

上一篇:吴恩达机器学习笔记44-核函数(Kernels)


下一篇:【Sqlserver】企业管理器打不开