I want to create a video sequence in Sprite Kit and use the following code:
@interface VideScreenNode()
@end
@implementation VideScreenNode
- (void)setupVideoSequence
{
AVPlayerItem * intro = [AVPlayerItem playerItemWithURL:[self geturlFromFileName:@"Video1" andType:@"mp4"]];
AVPlayerItem * video1 = [AVPlayerItem playerItemWithURL:[self geturlFromFileName:@"Video2" andType:@"mp4"]];
AVPlayerItem * video2 = [AVPlayerItem playerItemWithURL:[self geturlFromFileName:@"Video3" andType:@"mp4"]];
AVPlayerItem * video3 = [AVPlayerItem playerItemWithURL:[self geturlFromFileName:@"Video4" andType:@"mp4"]];
AVPlayerItem * video4 = [AVPlayerItem playerItemWithURL:[self geturlFromFileName:@"Video5" andType:@"mp4"]];
AVPlayerItem * outro = [AVPlayerItem playerItemWithURL:[self geturlFromFileName:@"Video6" andType:@"mp4"]];
AVQueuePlayer * queuePlayer = [[AVQueuePlayer alloc] initWithItems:@[intro, video1, video2, video3, video4, outro]];
SKVideoNode * sequenceNode = [[SKVideoNode alloc] initWithAVPlayer: queuePlayer];
sequenceNode.position = CGPointMake(512, 384);
[sequenceNode play];
[self addChild:sequenceNode];
}
#pragma mark - helper
- (NSURL *)geturlFromFileName:(NSString *)name
andType:(NSString *)type
{
return [NSURL fileURLWithPath: [[NSBundle mainBundle] pathForResource: name ofType:type]];
}
The video sequence works just fine, but there is a small interruption between each clip. How do I achieve a seamless transition?
Thanks in advance.