I am using two players one is MPMoviePlayerController and the other is AVPlayer. henever MPMoviePlayerController is seeked, it sets the time to AVPlayer. Everything is working fine. While converting MPMoviePlayerController current time to CMTime it is rounding off ex:(if mpplayer time is 11.80132 it is rounding to 11).
Without rounding off, how can we set the time to AVPlayer?
Code for getting mpplayer time and sending to AVPlayer class
[avplayerClass setCurrentTime:[self.videoPlayer currentPlaybackTime]];
NSLog(@"CurrentTime:%f",[self.videoPlayer currentPlaybackTime]);//11.801345
Code in AVPlayer class and converting time to 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));//11
NSLog(@"Current time123ns%%%%%%:%f",seekTime);//11.801345
}
Try this :
CMTime seekingCM = CMTimeMakeWithSeconds(playbackTime, 1000000);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With