iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – iOS – 强制全屏视频大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用MPMoviePlayerViewController.当视频加载并开始播放时,它不会填满整个屏幕.我必须按右上角的全屏按钮才能实现.如果我使用MPMoviePlayerController我根本无法让它填满屏幕.

通过代码,我可以使用MPMoviePlayerViewController全屏显示我的视频,而无需按全屏按钮?

我知道我在这里使用私有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];

}

这是一个屏幕.第一种是没有按下全屏按钮,第二种是在按下之后.

解决方法

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

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

我在家测试过它有效,所以我也希望你.

大佬总结

以上是大佬教程为你收集整理的iphone – iOS – 强制全屏视频全部内容,希望文章能够帮你解决iphone – iOS – 强制全屏视频所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: