0

H!我正在使用 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]]];
4

1 回答 1

0

解决了!刚刚在播放和停止之间添加了另一个动作(waitTime)并删除了 dispatch_async 和 usleep

于 2014-05-11T02:34:58.883 回答