/**
* 添加播放器通知,通过AVPlayerItemDidPlayToEndTimeNotification字段判断播放器播放情况
*/
-(
void)addNotification{
[[NSNotificationCenter defaultCenter] addObserver:self selector:
@selector(playbackFinished:) name:AVPlayerItemDidPlayToEndTimeNotification object:self.player.currentItem];
}
-(
void)removeNotification{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
/**
* 播放完成通知
*
* @param notification 通知对象
*/
-(
void)playbackFinished:(NSNotification *)notification{
NSLog(@
"视频播放完成.");
[_player seekToTime:CMTimeMake(
0,
1)];
[_player play];
}