我使用两个播放器,一个是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.801345AVPlayer类中的代码并将时间转换为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
}发布于 2016-07-19 04:47:11
试试这个:
CMTime seekingCM = CMTimeMakeWithSeconds(playbackTime, 1000000);https://stackoverflow.com/questions/18203943
复制相似问题