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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章