avplayer视频重复循环播放,视频重播

在视频播放完成的监听方法中执行重播方法

 [[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];
}

你可能感兴趣的:(OC)