Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c MPMoviePlayerController:全屏模式下有声音但没有图片_Objective C_Ios_Ipad_Mpmovieplayercontroller - Fatal编程技术网

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

Objective c MPMoviePlayerController:全屏模式下有声音但没有图片,objective-c,ios,ipad,mpmovieplayercontroller,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 not

我使用以下代码在运行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
调用,但没有效果

更新

这个问题似乎直接相关:


首先将此行更改为:
[[NSBundle mainBundle]pathForResource:@“myMovie.mov”类型:@“@”
将其更改为:
[[NSBundle mainBundle]pathForResource:@“mov”类型的“myMovie”
然后重试

将其用作我的工作:

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;

没有变化,但如果这真的影响了什么,我会感到惊讶。它帮你解决了一个问题吗?谢谢!有趣。我试过编写代码,最后一行似乎有所不同——电影播放器视图的设置直接替换当前视图,使视频可见。不幸的是,电影播放器显示了电影的侧面!这并不是问题的答案,但我已经切换到MPMoviePlayerViewController,它可以很好地用于全屏视频。