-
Notifications
You must be signed in to change notification settings - Fork 146
notification
isExist? edited this page Sep 22, 2016
·
8 revisions
- 播放器完成对视频文件的初始化时发送此通知
- 播放状态发生改变时发送此通知
- 正常播放结束或者因为错误播放失败时发送此通知
- userInfo字典中,关键字MPMoviePlayerPlaybackDidFinishReasonUserInfoKey指明了具体的结束原因,详细可参考MPMovieFinishReason
- 当结束原因为MPMovieFinishReasonPlaybackError时,userInfo字典中的关键字error指明了具体的错误码,详细可参考错误码
- 数据加载状态发生改变时发送此通知
- 第一次检测出视频的宽高或者播放过程中宽高发生改变时发送此通知
- 渲染第一帧视频时发送此通知
- 渲染第一帧音频时发送此通知
- 为提升开播速度,播放器在查找文件格式时只检查少量的数据,如果音视频数据交织情况较差,会导致播放器认为当前码流中只含有视频或者音频数据;但是在播放过程中,发现实际上存在着未检测到的音频或者视频流,此时播放器会发送此通知
- 当用户监听到此通知时,请务必调用- (void)reload:(NSURL *)aUrl flush:(bool)flush mode:(MPMovieReloadMode)mode方法,并将mode模式设置为MPMovieReloadMode_Accurate来重新加载码流
- 当播放过程中发生需要上层注意的事件时发送此通知,如实际采用的视频解码方式、解码出现错误等...
- userInfo字典中,关键字MPMoviePlayerPlaybackStatusUserInfoKey指明了发生的具体事件,相应可参考MPMovieStatus。
- 注册Observers
- (void)setupObservers
{
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(handlePlayerNotify:)
name:(MPMediaPlaybackIsPreparedToPlayDidChangeNotification)
object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(handlePlayerNotify:)
name:(MPMoviePlayerPlaybackStateDidChangeNotification)
object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(handlePlayerNotify:)
name:(MPMoviePlayerPlaybackDidFinishNotification)
object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(handlePlayerNotify:)
name:(MPMoviePlayerLoadStateDidChangeNotification)
object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(handlePlayerNotify:)
name:(MPMovieNaturalSizeAvailableNotification)
object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(handlePlayerNotify:)
name:(MPMoviePlayerFirstVideoFrameRenderedNotification)
object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(handlePlayerNotify:)
name:(MPMoviePlayerFirstAudioFrameRenderedNotification)
object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(handlePlayerNotify:)
name:(MPMoviePlayerSuggestReloadNotification)
object:nil];
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(handlePlayerNotify:)
name:(MPMoviePlayerPlaybackStatusNotification)
object:nil];
}
- 去注册Observers
- (void)releaseObservers
{
[[NSNotificationCenter defaultCenter]removeObserver:self
name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification
object:nil];
[[NSNotificationCenter defaultCenter]removeObserver:self
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:nil];
[[NSNotificationCenter defaultCenter]removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
[[NSNotificationCenter defaultCenter]removeObserver:self
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
[[NSNotificationCenter defaultCenter]removeObserver:self
name:MPMovieNaturalSizeAvailableNotification
object:nil];
[[NSNotificationCenter defaultCenter]removeObserver:self
name:MPMoviePlayerFirstVideoFrameRenderedNotification
object:nil];
[[NSNotificationCenter defaultCenter]removeObserver:self
name:MPMoviePlayerFirstAudioFrameRenderedNotification
object:nil];
[[NSNotificationCenter defaultCenter]removeObserver:self
name:MPMoviePlayerSuggestReloadNotification
object:nil];
[[NSNotificationCenter defaultCenter]removeObserver:self
name:MPMoviePlayerPlaybackStatusNotification
object:nil];
}