AVPalyer默認觀察員跟蹤視頻的當前時間,當您暫停或恢復播放視頻,你可以得到通過使用一個全局變量來暫停時間(在觀察者更新該變量的情況下)
CMTime interval = CMTimeMake(1,1);
//The capture of self here is coming in with your implicit property access of self.currentduration - you can't refer to self or properties on self from within a block that will be strongly retained by self.
//You can get around this by creating a weak reference to self before accessing timerDisp inside your block
__weak typeof(self) weakSelf = self;
self.timeObserverToken = [_player addPeriodicTimeObserverForInterval:interval queue:NULL usingBlock: ^(CMTime time)
{
_currentDuration = (int)CMTimeGetSeconds (_player.currentTime);
if(!_isPlaying)
{
_pausedDuration = _currentDuration;
}
}
有一種方法來監視是否AVPlayer播放這裏列出:http://stackoverflow.com/a/9288642/2383604 –