在视频播放完成的监听方法中执行重播方法
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidPlayToEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:nil];
- (void)playerItemDidPlayToEnd:(NSNotification *)notification{
[self rerunPlayVideo];
}
//视频重播
-(void)rerunPlayVideo{
if (!self.player) {
return;
}
CGFloat a=0;
NSInteger dragedSeconds = floorf(a);
CMTime dragedCMTime = CMTimeMake(dragedSeconds, 1);
[self.player seekToTime:dragedCMTime];
[self.player play];
}
本文介绍了一种实现视频播放完成后自动重播的方法。通过监听视频播放结束的通知并在回调中调用重播函数,实现了无缝循环播放的效果。具体步骤包括设置通知中心监听、定义播放结束回调函数以及实现视频重播逻辑。
1万+

被折叠的 条评论
为什么被折叠?



