我正在使用MPMoviePlayerController
在CCMenu
的背景中播放视频。所以我在一些按钮后面播放视频。当我切换视图/场景时,我希望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
}
这很完美,在app委托中我也改变了
CCGLView *glView = [CCGLView viewWithFrame:[window_ bounds]
pixelFormat:kEAGLColorFormatRGB565 // To kEAGLColorFormatRGBA8
最后我想像这样翻页:
[[CCDirector sharedDirector] replaceScene: [CCTransitionPageTurn transitionWithDuration:1.0 scene:[FirstPageViewController scene]]];
但只有精灵会离开现场,视频会在后台播放。我怎样才能解决这个问题?提前致谢
答案 0 :(得分: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
Happy Coding everyone:)