2014-05-11 73 views
0

H!我正在使用SKVideoNode在項目上播放視頻。事情是,當我試圖阻止它並回到當前的行動有時它有效,但有時不行。停止並退出SKVideo

這裏是我玩的代碼。提前致謝。

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

解決了!剛加入遊戲之間的另一個動作(WAITTIME)停止並刪除dispatch_async和usleep