spe*_*tak 5 iphone mpmovieplayercontroller ipad 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];
}
Run Code Online (Sandbox Code Playgroud)
这是一个屏幕.第一种是没有按下全屏按钮,第二种是在按下之后.
Yan*_*iot 14
您必须将fullscreen属性设置为true,并将scallingMode设置为aspect填充,如下所示:
if (moviePath)
{
NSURL *url = [NSURL fileURLWithPath:moviePath];
player = [[MPMoviePlayerViewController alloc]initWithContentURL:url];
player.moviePlayer.fullscreen = YES;
player.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
}
Run Code Online (Sandbox Code Playgroud)
我在家测试过它有效,所以我也希望你.
归档时间: |
|
查看次数: |
7958 次 |
最近记录: |