0

我正在使用MPMoviePlayerControllerCCMenu. 所以我在一些按钮后面播放了一段视频。当我切换视图/场景时,我希望moviePlayer让场景与该层/场景上的按钮/图像相同。

后台播放电影的代码如下:

-(void)playMainMenuVideo{
NSString *path=[[NSBundle mainBundle] pathForResource:@"MYMMainMenu" ofType:@"mov"];
MPMoviePlayerViewController * player=[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];
player.moviePlayer.controlStyle = MPMovieControlStyleNone;
[[player view] setFrame:[[[CCDirector sharedDirector]view] bounds]];
player.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
[[[CCDirector sharedDirector]view] addSubview:[player view]];
[[[CCDirector sharedDirector]view] sendSubviewToBack:player.view];
UIView* glView = [CCDirector sharedDirector].view; // attention
[glView.superview insertSubview:player.view atIndex:0]; // attention
glView.opaque = NO; // attention
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // attention
}

这很完美,在应用程序委托中我也改变了

CCGLView *glView = [CCGLView viewWithFrame:[window_ bounds]
                               pixelFormat:kEAGLColorFormatRGB565 // To kEAGLColorFormatRGBA8

最后我想做一个这样的翻页:

        [[CCDirector sharedDirector] replaceScene: [CCTransitionPageTurn transitionWithDuration:1.0 scene:[FirstPageViewController scene]]];

但只有精灵会离开场景,视频会在后台播放。我怎样才能解决这个问题?提前致谢

4

1 回答 1

0

我想到了。

1) 设置视频播放完毕时的通知。2) 播放完成后,将视频最后一帧的图像放在视频上。3)然后将这些属性设置回原来的

UIView* glView = [CCDirector sharedDirector].view; // attention
glView.opaque = YES; // attention
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

4)删除MPMoviePlayerController

祝大家编码愉快:)

于 2013-06-21T02:54:48.100 回答