AVPlayer跳过video的开头

当我试图在预滚动后立即播放时,我正在尝试AVPlayer跳过我正在播放的video的前0.5秒。

首先,我创建了播放器:

self.videoPlayer = [[AVPlayer alloc] init]; 

然后,我将播放器项目添加到播放器并添加一个观察者来检查并查看该项目何时准备好:

 [self.videoPlayer addObserver:self forKeyPath:@"currentItem" options:0 context:kBLCurrentPlayerItemStatusContext]; [self.videoPlayer replaceCurrentItemWithPlayerItem:self.currentVideoPlayerItem]; 

当观察到玩家项目时,我将检查玩家是否准备好玩。 如果还没准备好玩,我会添加一个观察者来确保它已经准备好了:

 -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ ... } else if (context == kBLCurrentPlayerItemStatusContext) { [self.videoPlayer removeObserver:self forKeyPath:@"currentItem" context:&kBLCurrentPlayerItemStatusContext]; if ([self.videoPlayer status]==AVPlayerStatusReadyToPlay) { [self prerollVideoPlayer]; } else { [self.videoPlayer addObserver:self forKeyPath:@"status" options:0 context:&kBLVideoPlayerStatusContext]; } } ... 

当观察到玩家状态准备好玩时,我会预先注册玩家:

 -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ ... if (context == kBLVideoPlayerStatusContext) { if ([self.videoPlayer status] == AVPlayerStatusReadyToPlay) { [self.videoPlayer removeObserver:self forKeyPath:@"status" context:&kBLVideoPlayerStatusContext]; [self prerollVideoPlayer]; } } ... 

在前贴片完成后,我播放播放器:

 -(void)prerollVideoPlayer{ [self.videoPlayer prerollAtRate:1.0 completionHandler:^(BOOL finished){ if (finished) { [self.videoPlayer play]; } }]; } 

当玩家以这种方式玩游戏时,它会跳过video的前0.5秒。 如果我没有让播放器在完成预滚动时立即播放,我稍后调用播放方法就可以正常播放。 我已经检查过以确保所有观察者都被正确观察到并且它们按照我上面提到的顺序发生。 是否有我需要添加的观察者或我应该检查的通知以避免这种跳过行为?