gpt4 book ai didi

iOS : How to Full screen video when change device orientation to Landscape in MPMoviePlayerController?

转载 作者:行者123 更新时间:2023-11-29 02:31:33 25 4
gpt4 key购买 nike

我正在使用 MPMoviePlayerController 开发应用程序。该应用程序仅支持纵向模式。但是,当我将设备方向更改为横向时,我想将视频更改为全屏,而当将设备方向更改为纵向时,我想更改为半屏。

如果在横向和全屏模式下电影结束,则也进入半屏模式。

我尝试了不同的代码和选项,但都没有成功。请帮忙。

我的源代码

@property (nonatomic,strong) MPMoviePlayerController* moviePlayer;

-(void)PlayVideoContent
{
CGFloat x = 0;
CGFloat y = 70;
CGRect mpFrame = CGRectMake(x, y, SCREEN_WIDTH, 200);

NSString * introVideoFileName = @"video_5.mp4";
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:introVideoFileName ofType:@""]];

MPMoviePlayerController *controller = [[MPMoviePlayerController alloc] initWithContentURL:url];
controller.scalingMode = MPMovieScalingModeAspectFill;

self.moviePlayer = controller; //Super important
// controller.view.frame = self.view.bounds; //Set the size
controller.view.frame = mpFrame; //Set the size
// [self.moviePlayer setFullscreen:YES animated:YES];

[self.view addSubview:self.moviePlayer.view]; //Show the view
[self.moviePlayer play]; //Start playing
}

最佳答案

你必须给你的应用程序的 UIViewController(s) 来决定它是在 landscape 还是 portrait 中。

在那之后,除了你想要横向的那个(MPMoviePlayerController)之外,将所有其他设置为纵向

关于iOS : How to Full screen video when change device orientation to Landscape in MPMoviePlayerController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26803397/

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