(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];
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。