我使用AVPlayer和UISlider作为视频播放的擦洗器。 以下是代码:
__weak __typeof__(self) weakSelf = self;
avPlayerTimeObserver_ = [_avPlayer addPeriodicTimeObserverForInterval:CMTimeMake(1, 10)
queue:dispatch_get_main_queue()
usingBlock:^(CMTime time) {
if (weakSelf.avPlayer.status == AVPlayerStatusReadyToPlay && weakSelf.avPlayer.currentItem.status == AVPlayerItemStatusReadyToPlay) {
NSTimeInterval currentTime = CMTimeGetSeconds(_avPlayer.currentItem.currentTime);
NSLog("currentTime: %@");
[self.playerView.scrubber setValue:currentTime];
}
}];
通过检查登录控制台,滑块的值在一秒内设置了很多次:
2014-07-28 10:41:07.044 TestAVPlayer[16733:90b] currentTime: 19.609156 2014-07-28 10:41:07.145 TestAVPlayer[16733:90b] currentTime: 19.709789 2014-07-28 10:41:07.245 TestAVPlayer[16733:90b] currentTime: 19.809995 2014-07-28 10:41:07.345 TestAVPlayer[16733:90b] currentTime: 19.909412 2014-07-28 10:41:07.445 TestAVPlayer[16733:90b] currentTime: 20.009458 2014-07-28 10:41:07.545 TestAVPlayer[16733:90b] currentTime: 20.109446 2014-07-28 10:41:07.644 TestAVPlayer[16733:90b] currentTime: 20.209153 2014-07-28 10:41:07.744 TestAVPlayer[16733:90b] currentTime: 20.309311 2014-07-28 10:41:07.844 TestAVPlayer[16733:90b] currentTime: 20.409178 2014-07-28 10:41:07.944 TestAVPlayer[16733:90b] currentTime: 20.509420 2014-07-28 10:41:08.045 TestAVPlayer[16733:90b] currentTime: 20.610105 2014-07-28 10:41:08.144 TestAVPlayer[16733:90b] currentTime: 20.709268 2014-07-28 10:41:08.245 TestAVPlayer[16733:90b] currentTime: 20.809690 2014-07-28 10:41:08.345 TestAVPlayer[16733:90b] currentTime: 20.909868
但滑块的拇指每隔1秒一步一步地移动,我设置间隔CMTimeMake(1,10)或CMTimeMake(1,30)甚至CMTimeMake(1,100)
如何让它变得更加温暖?