1) 寻找起始位置:
int32_t preferredTimeScale = 600;
CMTime inTime = CMTimeMakeWithSeconds(self.startTime, preferredTimeScale);
[mainPlayer seekToTime:inTime];
2)设置定时器:
_EndOFRegionCheckTimer = [NSTimer scheduledTimerWithTimeInterval:0.10f
target:self
selector:@selector(_checkEndPassedFired)
userInfo:nil
repeats:YES];
3)在计时器火灾事件中检查当前位置并在必要时停止播放:
- (void)_checkEndPassedFired {
AVPlayerItem *currentItem = mainPlayer.currentItem;
if ((double)currentItem.currentTime.value/currentItem.currentTime.timescale>self.stopTime)
{
[mainPlayer pause];
}
}