gpt4 book ai didi

iphone - iOS - 强制全屏视频

转载 作者:可可西里 更新时间:2023-11-01 04:15:01 24 4
gpt4 key购买 nike

我正在使用 MPMoviePlayerViewController。当视频加载并开始播放时,它不会填满整个屏幕。我必须按下右上角的全屏按钮才能实现。如果我使用 MPMoviePlayerController,我根本无法让它填满屏幕。

有什么方法可以通过代码使用 MPMoviePlayerViewController 让我的视频全屏显示而无需按全屏按钮?

我知道我在这里使用的是私有(private) API,不过没关系,它只是为了演示。

代码:

- (void)viewDidLoad
{
[super viewDidLoad];


[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait];
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"phatpad" ofType:@"mov"];

if (moviePath)
{
NSURL *url = [NSURL fileURLWithPath:moviePath];
player = [[MPMoviePlayerViewController alloc]initWithContentURL:url];
}

player.view.frame = self.view.frame;

[self.view addSubview: player.view];

}

这是一个屏幕。第一个是没有按下全屏按钮,第二个是在按下它之后。 enter image description here

最佳答案

您必须将 fullscreen 属性设置为 true 并将 scallingMode 设置为纵横比填充,如下所示:

if (moviePath)
{
NSURL *url = [NSURL fileURLWithPath:moviePath];
player = [[MPMoviePlayerViewController alloc]initWithContentURL:url];
player.moviePlayer.fullscreen = YES;
player.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
}

我已经在家里测试过并且有效,所以我希望你也能。

关于iphone - iOS - 强制全屏视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7179802/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com