2011-03-15 56 views
0

这可能吗?我想是的,但我无法弄清楚。在Cocos2D Mac中使用QTMovieView?

因此,对于电影中的代码迄今:

shrigString = [[一个NSBundle mainBundle] pathForResource:@ “shrig_h264_720p” ofType:@ “MOV”]; shrigURL = [NSURL fileURLWithPath:shrigString]; // shrigMovie = [QTMovie movieWithFile:@“shrig_h264_720p.mov”error:nil]; shrigMovie = [QTMovie movieWithURL:shrigURL error:nil]; shrigMovieView = [QTMovieLayer layerWithMovie:shrigMovie];

[[[[CCDirectorMac sharedDirector] openGLView] window] addChildWindow:shrigWindow ordered:NSWindowAbove]; 
    [shrigWindow setContentView:shrigNSView]; 
    [shrigNSView setLayer:shrigMovieView]; 
    shrigMovieView.frame = CGRectMake(size.width /2, size.height /2, 1024, 576); 
    [shrigMovie autoplay]; 
    [shrigMovie play]; 

    NSLog(@"shrigMovie: %@", shrigMovie); 
    NSLog(@"shrigMovie is: %@", QTStringFromTime([shrigMovie currentTime])); 

但是,我无法弄清楚如何广告到我的场景。这是Mac btw的Cocos2D。

在控制台:

shrigMovie 0:00:00:00.00/2500所以我想它加载好,但根本不显示?

任何想法将非常赞赏。

谢谢。

回答

0

我遇到了同样的问题,花了很长时间试图找出如何使用QTMovie与cocos2D结合解决它。最终我放弃了,开始寻找是否有一个好的现有解决方案。瞧,我发现了VideoPlayer。非常容易使用,非常轻便,您可以在https://github.com/psineur/CCVideoPlayer上找到它。只需确保只复制zip文件中必需的VideoPlayer文件夹,并且不要忘记Resources文件夹中的CustomVideoView.nib。在项目中添加的一些LIB文件夹中,然后就可以开始播放使用这两条线视频文件:

[VideoPlayer setDelegate:self]; 
[VideoPlayer playMovieWithFile:@"intro.mov"]; 

然后,您可以添加下面的委托方法到类

- (void) moviePlaybackFinished 
{ 
} 

- (void) movieStartsPlaying 
{ 
} 

了它在不到10分钟内工作:)

干杯