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

标签 ios objective-c iphone mpmovieplayercontroller

我正在使用 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/

相关文章:

ios - 在 iOS 7.0 发布时将带有基本 SDK iOS 6.1 的应用程序提交到 App Store

ios - 使用 Masonry 在它的 super View 中居中 View

ios - Swift 编译器错误 : "Expression too complex" on a string concatenation

ios - 图片下载 - NSURLSession 收到身份验证挑战

objective-c - 代码 "Could not launch Game Name, no such file or directory..."

iphone - 如何在 Facebook 上发布带有 url 的消息?

iphone - Array addObject 正在更改所有数组值,而不仅仅是附加

ios - 仅限 iOS 上的 React Native 62 无法识别的字体系列

Objective-C 实例变量/属性的多重声明

ios:将新数据加载到 UICollectionView 中