我正在使用两个播放器,一个是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
}