ios视频循环播放实现

xiaoxiao2021-02-28  78

/** * 添加播放器通知,通过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]; }
转载请注明原文地址: https://www.6miu.com/read-64314.html

最新回复(0)