/**
* 添加播放器通知,通过AVPlayerItemDidPlayToEndTimeNotification字段判断播放器播放情况
*/
-(void)addNotification{
//给AVPlayerItem添加播放完成通知
[[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];
}
ios视频循环播放实现
最新推荐文章于 2024-07-29 16:01:12 发布