2
新增KVO
爲AVPlayer
時播放視頻作爲queuePlayer
是AVPlayer
AVPlayer設置的初始播放時間的iOS
[self.queuePlayer addObserver:self forKeyPath:@"status" options:0 context:NULL];
observer
method
:
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([keyPath isEqualToString:@"status"]) {
if (self.queuePlayer.status == AVPlayerStatusReadyToPlay) {
NSInteger step = (NSInteger)(startTimeForVideo/0.04);
[self.queuePlayer.currentItem stepByCount:step];
//CMTime seekTime = CMTimeMake(startTimeForVideo*timeScale,timeScale);
//if (CMTIME_IS_VALID(seekTime))
// [self.queuePlayer seekToTime:seekTime toleranceBefore:kCMTimePositiveInfinity toleranceAfter:kCMTimePositiveInfinity];
//else
// NSLog(@"In valid time");
[self.queuePlayer play];
} else if (self.queuePlayer.status == AVPlayerStatusFailed) {
/* An error was encountered */
}
}
這裏startTimeForVideo
INTIAL playBack time
爲video
seekToTime
不工作也不stepByCount
編輯:中object
Values
用於methods
是correct
而且即使no luck