我将视频加载到我的精灵套件SKVideoNode中,但是如何停止并重新开始播放或转到视频中的特定时间?我看到的只是播放和暂停方法。
// 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;
你能用SKVideoNode做的事情都记录在这里。 play
和pause
是唯一受支持的播放方法。
没有停止,因为它相当于在这种情况下的暂停 - "停止"应该做什么,渲染黑色纹理?如果SKVideoNode应该在"停止"时被删除,那么只需向它发送removeFromParent
消息,就会"停止"它。
倒带是不必要的,因为您可以简单地再次运行play
方法或创建新的SKVideoNode。
我假设不支持跳转到特定时间范围,因为这不可能是即时的,因此再次存在节点在视频播放位置移动到指定时间戳之前应该显示什么的问题?
如果保留对用于初始化视频节点的 AVPlayer
对象的引用,则可以使用其方法控制播放