无法全屏显示 MPMoviePlayerViewController 或 MoviePlayerController

发布于 2024-12-08 01:10:00 字数 1637 浏览 0 评论 0原文

我正在尝试创建一部在我的应用程序启动时播放的电影。第一个视图控制器是 UITabBarController。在第一个选项卡的视图控制器的代码中,是我放置电影的位置。这个虚拟代码有效(将框架设置为小于全屏并仅显示视频):

- (void)PlayOpeningMovie {
    NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"test" ofType:@"m4v"];  
    NSURL    *fileURL    =   [NSURL fileURLWithPath:filepath];  
    MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];  
//    MPMoviePlayerViewController *moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
    [moviePlayerController.view setFrame:CGRectMake(120, 120, 300, 200)];

    [[NSNotificationCenter defaultCenter] addObserver:self  
                                             selector:@selector(moviePlaybackComplete:)  
                                                 name:MPMoviePlayerPlaybackDidFinishNotification  
                                               object:moviePlayerController];  
    [self.view addSubview:moviePlayerController.view];  
//    [moviePlayerController setFullscreen:YES];
//    [self presentMoviePlayerViewControllerAnimated:moviePlayerController];

    [moviePlayerController play];  
//    [[moviePlayerController moviePlayer] play];
}

但是,如果我切换它,注释掉 setFrame 方法并使用全屏属性,我就看不到电影。

我还尝试创建一个 MPMovieplayerViewController 并使用 MPMoviePlayerViewControllers 的方法以模态方式呈现它,但它从未呈现出来,我不明白为什么。我也尝试创建一个具有黄色背景的虚拟视图控制器,并以模态方式呈现它,但这也不起作用。

我尝试在屏幕上添加一个虚拟 UIView,效果很好。

因此,出于某种原因,我可以使用 addSubview 来显示小型 UIViews/MPMoviePlayers。我无法让presentModal__工作。我无法让全屏模式适用于 MoviePlayerController。我真的很困惑为什么我不能从这个角度来模态地呈现。谢谢。

I'm trying to create a movie to play when my app starts up. The first view Controller is a UITabBarController. In the code for the view controller for the first tab, is where I put my movie. This dummy code works (setting the frame to be smaller than the full screen and just showing the video):

- (void)PlayOpeningMovie {
    NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"test" ofType:@"m4v"];  
    NSURL    *fileURL    =   [NSURL fileURLWithPath:filepath];  
    MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];  
//    MPMoviePlayerViewController *moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
    [moviePlayerController.view setFrame:CGRectMake(120, 120, 300, 200)];

    [[NSNotificationCenter defaultCenter] addObserver:self  
                                             selector:@selector(moviePlaybackComplete:)  
                                                 name:MPMoviePlayerPlaybackDidFinishNotification  
                                               object:moviePlayerController];  
    [self.view addSubview:moviePlayerController.view];  
//    [moviePlayerController setFullscreen:YES];
//    [self presentMoviePlayerViewControllerAnimated:moviePlayerController];

    [moviePlayerController play];  
//    [[moviePlayerController moviePlayer] play];
}

However, if I switch it around, comment out the setFrame method, and use the fullscreen property, I do not see the movie.

I was also playing around with creating a MPMovieplayerViewController and presenting that modally with the method for the MPMoviePlayerViewControllers, but it never gets presented and I can't figure out why. I tried creating a dummy viewController with a yellow background as well, and presenting that modally and that does not work either.

I have tried adding a dummy UIView to the screen, and that works.

So for some reason, I can get small UIViews/MPMoviePlayers to show with addSubview. I cannot get the presentModal__ to work. I cannot get fullscreen mode to work for the MoviePlayerController. I'm really stumped as to why I cannot present modally from this view. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

单调的奢华 2024-12-15 01:10:00
[moviePlayerController setControlStyle:MPMovieControlStyleFullscreen];

[moviePlayerController setFullscreen:YES];

只需添加这两行即可全屏显示。

[moviePlayerController setControlStyle:MPMovieControlStyleFullscreen];

[moviePlayerController setFullscreen:YES];

Just add this two lines to present it in full screen.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文