如何控制iOS Sprite Kit SKVideoNode中video的播放?

我将video加载到我的Sprite Kit SKVideoNode中,但是如何停止并重新开始播放或在video的特定时间? 我所看到的只是播放和暂停的方法。

// AVPlayer NSURL *fileURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"HowToPlay" ofType:@"mp4"]]; _avPlayer = [AVPlayer playerWithURL:fileURL]; // SKVideoNode _videoNode = [SKVideoNode videoNodeWithAVPlayer:_avPlayer]; [_videoNode play]; 

这原来是为我工作。

重新开始:

 [_videoNode removeFromParent]; _videoNode = [SKVideoNode videoNodeWithVideoFileNamed:@"video.mp4"]; _videoNode.position = ... _videoNode.size = ... [self addChild:_videoNode]; [_videoNode play]; 

暂停:

 [_videoNode pause]; _videoNode.paused = YES; 

玩:

 [_videoNode play]; _videoNode.paused = NO; 

这里logging了您可以使用SKVideoNode做的所有事情。 playpause是唯一支持的播放方法。

没有停止,因为它相当于在这种情况下停顿 – 应该“停止”什么,呈现黑色纹理? 如果SKVideoNode在“停止”时应该被删除,那么只要发送removeFromParent消息,就可以“停止”它。

倒带是不必要的,因为您可以简单地再次运行play方法或创build一个新的SKVideoNode。

我认为跳转到一个特定的时间范围是不被支持的,因为这不可能是即时的,所以再次存在节点应当在video播放位置被移动到指定的时间戳之前显示什么的问题?

如果保留对用于初始化video节点的AVPlayer对象的引用,则可以使用其方法控制回放