0

我正在使用以下代码在运行 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 在全屏问题(显示空白黑屏)

4

2 回答 2

0

首先将这一行 : 更改
[[NSBundle mainBundle] pathForResource:@"myMovie.mov" ofType:@""]为:
[[NSBundle mainBundle] pathForResource:@"myMovie" ofType:@"mov"]并重试

于 2012-09-28T10:35:09.540 回答
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;
于 2012-09-28T10:43:20.110 回答