8

我正在使用两个播放器,一个是MPMoviePlayerController,另一个是AVPlayer。无论何时MPMoviePlayerController被寻找,它都会将时间设置为AVPlayer。一切正常。将MPMoviePlayerController当前时间转换为CMTime它正在四舍五入 ex:(如果 mpplayer 时间为 11.80132,则四舍五入为 11)。

如果不四舍五入,我们如何将时间设置为AVPlayer

获取 mpplayer 时间并发送到AVPlayer课堂的代码

[avplayerClass  setCurrentTime:[self.videoPlayer currentPlaybackTime]];
NSLog(@"CurrentTime:%f",[self.videoPlayer currentPlaybackTime]);//11.801345

课堂上的代码AVPlayer并将时间转换为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
}
4

1 回答 1

6

尝试这个 :

  CMTime seekingCM = CMTimeMakeWithSeconds(playbackTime, 1000000);
于 2016-07-18T20:47:11.053 回答