Iphone 背景中的MPMoviePlayerController不';我们换场景时不要离开页面

Iphone 背景中的MPMoviePlayerController不';我们换场景时不要离开页面,iphone,ios,cocos2d-iphone,Iphone,Ios,Cocos2d Iphone,我正在使用MPMoviePlayerController在CCMenu的背景中播放视频。所以我在一些按钮后面放了一个视频。切换视图/场景时,我希望moviePlayer使场景与该层/场景上的按钮/图像保持一致 在后台播放电影的代码如下: -(void)playMainMenuVideo{ NSString *path=[[NSBundle mainBundle] pathForResource:@"MYMMainMenu" ofType:@"mov"]; MPMoviePlayerViewCon

我正在使用
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
}
这很好用,在应用程序中,我也更改了代理

CCGLView *glView = [CCGLView viewWithFrame:[window_ bounds]
                               pixelFormat:kEAGLColorFormatRGB565 // To kEAGLColorFormatRGBA8
最后,我想做这样的翻页:

        [[CCDirector sharedDirector] replaceScene: [CCTransitionPageTurn transitionWithDuration:1.0 scene:[FirstPageViewController scene]]];
但只有精灵会离开场景,视频仍在背景中播放。我怎样才能解决这个问题?提前谢谢

我弄明白了

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

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

大家好:)