I use two players: MPMoviePlayerController and the other is AVPlayer . who is looking for MPMoviePlayerController , he sets the AVPlayer time. Everything is working fine. Converting the MPMoviePlayerController current time to CMTime , it rounds ex: (if mpplayer time is 11.80132, round to 11).
Without rounding, how can we set the time on AVPlayer ?
Code to get mpplayer time and send to AVPlayer class
[avplayerClass setCurrentTime:[self.videoPlayer currentPlaybackTime]]; NSLog(@"CurrentTime:%f",[self.videoPlayer currentPlaybackTime]);
Code in AVPlayer class and CMTime conversion CMTime
-(void)setCurrentTime:(NSTimeInterval)seekTime { CMTime seekingCM = CMTimeMake(seekTime, 1); [self.player seekToTime:seekingCM toleranceBefore:kCMTimeZero toleranceAfter:kCMTimePositiveInfinity]; [self.player seekToTime:seekingCM]; NSLog(@"Current time123ns%%%%%%:%f",CMTimeGetSeconds(seekingCM));
source share