- (id)addPeriodicTimeObserverForInterval:(CMTime)interval queue:(dispatch_queue_t)queue usingBlock:(void (^)(CMTime time))block;
这个函数来控制获取时间的刷新率
例如:
[_LGCustomMoviePlayerController.player addPeriodicTimeObserverForInterval:CMTimeMake(1, 1) queue:NULL usingBlock:^(CMTime time){
//获取当前时间
CMTime currentTime = _LGCustomMoviePlayerController.player.currentItem.currentTime;
//转成秒数
double currentPlayTime = currentTime.value/currentTime.timescale;
//进度条的value
_movieProgressSlider.value = currentPlayTime/totalMovieDuration;
//把时间转化成 NSDate 格式
NSDate *d = [NSDate dateWithTimeIntervalSince1970:currentPlayTime];
// d 的打印形式为:1970——1——1 xx:xx:xx 我们需要的是 xx:xx:xx,然后进行显示
NSString *currentTimeStr = [NSString stringWithFormat:@"%@",d];
NSRange range;
range.location = 11;
range.length = 8;
NSString *showtime = [currentTimeStr substringWithRange:range];
self.currentTimeLabel.text = showtime;
}];