/**
* 添加播放器通知,通過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視頻循環播放實現
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.