MPMoviePlayerController:声音但在全屏模式下没有图片

时间:2012-09-28 10:31:41

标签: objective-c ios ipad mpmovieplayercontroller

我正在使用以下代码在运行iOS6的iPad 1上播放电影:

    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"myMovie.mov" ofType:@""]];
    self.moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];

    // Register to receive a notification when the movie has finished playing.
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(moviePlayBackDidFinish:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:self.moviePlayer];

    // Use the new 3.2 style API
    self.moviePlayer.controlStyle = MPMovieControlStyleDefault;

    [self.moviePlayer prepareToPlay];

    self.moviePlayer.view.frame = CGRectMake(0, 0, 1024, 768);

    [self.uiView addSubview:self.moviePlayer.view];

     //[self.moviePlayer setFullscreen:YES animated:YES];

     [self.moviePlayer play];

这很有效。

但是,如果我取消注释setFullscreen的行,我会获得电影音频,但屏幕全黑,没有图片。

我尝试更改几行的顺序,特别是play来电和setFullscreen来电,但没有效果。

更新

这个问题似乎直接相关:

MPMoviePlayerController in full screen issue (showing blank black screen)

2 个答案:

答案 0 :(得分:0)

首先更改此行:
[[NSBundle mainBundle] pathForResource:@"myMovie.mov" ofType:@""]至:[[NSBundle mainBundle] pathForResource:@"myMovie" ofType:@"mov"]然后重试

答案 1 :(得分:0)

使用它作为我的工作:

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"myMovie" ofType:@"mov"]];
MPMoviePlayerViewController *movieView = [[MPMoviePlayerViewController alloc]initWithContentURL:url];
movieView.moviePlayer.scalingMode =  MPMovieScalingModeFill;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
        [movieView.moviePlayer.view setFrame:CGRectMake(0,0,480,320)];
else
        [movieView.moviePlayer.view setFrame:CGRectMake(0,0,1024,768)];
movieView.moviePlayer.view.userInteractionEnabled = FALSE;
movieView.moviePlayer.controlStyle=0;
[movieView setFullscreen:YES];
self.view=movieView.view;