ħ!我正在使用SKVideoNode在项目上播放视频。问题在于,当我试图阻止它并回到当前的行动时,它有时会起作用,但有时却不起作用。
这是我播放它的代码。提前谢谢。
SKAction *actionPlayVideo = [SKAction runBlock:^{
SKVideoNode *introVideoLevel1 = [SKVideoNode videoNodeWithVideoFileNamed:@"escenario_intermedio.mov"];
introVideoLevel1.position = CGPointMake(CGRectGetMidX(self.frame),CGRectGetMidY(self.frame));
[introVideoLevel1 setName:@"IntroVideo"];
introVideoLevel1.size = CGSizeMake(ipad_2_width, ipad_2_height);
[self addChild: introVideoLevel1];
[introVideoLevel1 play];
}];
SKAction *actionStopVideo = [SKAction runBlock:^{
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
usleep(6900000);
//[[self childNodeWithName:@"IntroVideo"] stop];
[[self childNodeWithName:@"IntroVideo"] removeFromParent];
});
}];
[self runAction:[SKAction sequence:@[actionPlayVideo, actionStopVideo]]];
答案 0 :(得分:0)
解决了!只是在播放和停止之间添加了另一个动作(waitTime)并删除了dispatch_async和usleep