8

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
}
Till
  • 27,559
  • 13
  • 88
  • 122
kmReddy
  • 143
  • 2
  • 7

1 Answers1

7

Try this :

  CMTime seekingCM = CMTimeMakeWithSeconds(playbackTime, 1000000);
Jenel Ejercito Myers
  • 2,553
  • 2
  • 16
  • 24