(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];
}
posted on 2015-04-26 16:17 狗尾草-大数据收割基 阅读(1748) 评论(0) 编辑 收藏 举报