MPMoviePlayerController视图方向因iphone 3g和4g而异

时间:2011-11-10 11:59:04

标签: objective-c cocos2d-iphone mpmovieplayercontroller

我正在尝试在我的cocos2d游戏中使用MPMoviePlayerController在iPhone上播放.m4v格式的全屏风景视频。在4g设备上一切正常,但在3g视频有屏幕尺寸但垂直方向,所以我只能看到电影的左侧。我不确定问题是MPMoviePlayerController还是cocos2d gl视图。这是我的代码:

    NSString *url = [[NSBundle mainBundle] pathForResource:@"intro" ofType:@"m4v"];
    player = [[[MPMoviePlayerController alloc] initWithContentURL: [NSURL fileURLWithPath:url]] retain];

    [player.view setFrame: [[CCDirector sharedDirector] openGLView].bounds]; 
    if ([player respondsToSelector:@selector(setFullscreen:animated:)]) {  
        // Use the new 3.2 style API  
        player.controlStyle = MPMovieControlStyleNone;  
        player.shouldAutoplay = YES;  
        CGSize winSize = [[CCDirector sharedDirector] winSize];  
        CGRect rScreen;
        rScreen.origin.x = 0;
        rScreen.origin.y = 0;
        rScreen.size.width = winSize.width;
        rScreen.size.height = winSize.height;
        player.view.frame = rScreen;  
    } else {
        // Use the old 2.0 style API  
        player.movieControlMode = MPMovieControlModeHidden;  
    } 
    [[[CCDirector sharedDirector] openGLView] addSubview:player.view];  
    [player play];

如何在3g设备上播放视频?谢谢你的帮助!

0 个答案:

没有答案