简体   繁体   English

当我在iOS 8中旋转时,MPMediaPlayer变小

[英]MPMediaPlayer becomes small when i rotate it in ios 8

I have application which plays video. 我有播放视频的应用程序。 It was great and good working in ios7 but now in iOs8 it is broken 在ios7中工作很棒,但是现在在iOs8中已经坏了

self.player = [[MPMoviePlayerController alloc] initWithContentURL:self.videoFileToDisplay];
[self.player play];

[self.view setBackgroundColor:[UIColor redColor]];
[self.player.view setBackgroundColor:[UIColor greenColor]];
UIView *playerView = self.player.view;

[self.view addSubview:playerView];
playerView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[playerView]|"
                                                                  options:0
                                                                  metrics:nil
                                                                    views:NSDictionaryOfVariableBindings(playerView)]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[playerView]|"
                                                                  options:0
                                                                  metrics:nil

Also depending on horizontal or vertical video it is i need to rotate it 另外取决于水平或垂直视频,我需要旋转它

- (void)adoptVideoToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation withDuration:(NSTimeInterval)duration
{

    CGFloat horizontalVideoAngle = 0;
    CGFloat verticalVideoAngle = 0;

    switch (toInterfaceOrientation) {
        case UIDeviceOrientationLandscapeLeft:
            horizontalVideoAngle = 0;
            verticalVideoAngle = M_PI_2;
            break;
        case UIDeviceOrientationLandscapeRight:
            horizontalVideoAngle = 0;
            verticalVideoAngle = -M_PI_2;
            break;
        case UIDeviceOrientationPortraitUpsideDown:
            verticalVideoAngle = 0;
            horizontalVideoAngle = M_PI_2;
            break;
        case UIDeviceOrientationPortrait:
            verticalVideoAngle = 0;
            horizontalVideoAngle = -M_PI_2;
            break;
        default:
            return;
    }

    CGFloat angle = [self isHorizontalVideo] ? horizontalVideoAngle : verticalVideoAngle;
    self.player.view.transform = CGAffineTransformMakeRotation( angle );
}

It is good at all orientations except portrait. 除肖像外,它在所有方向上都很好。 Even UpsideDown is good Here are screenshots 甚至UpsideDown也不错这是屏幕截图

肖像景观权上下翻转景观左

What is wrong with portrait orientation in ios8 ? ios8中的纵向方向有什么问题?

PS red view is background of mediaPlayer superview PS红色视图是mediaPlayer Superview的背景

Looks like Apple changed rotation in ios8 now it rotates content only and doesn't affect view frame. 看起来Apple改变了ios8的旋转方式,现在它仅旋转内容且不影响视图框架。 So i ended up adding additional scale transform 所以我最终添加了额外的比例转换

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Swift iOS MPMediaPlayer 应用程序中切换播放列表和设置计时器的问题 - Problems switching between playlists and setting timers in Swift iOS MPMediaPlayer app 旋转iOS屏幕时,收藏夹视图单元出现问题 - When I rotate iOS screen, collection view cell is going wrong 旋转设备时,iOS模拟器为什么显示空白屏幕? - Why is iOS simulator displaying blank screen when I rotate device? IOS - 当我旋转 UIView 时,边缘会变形 - IOS - When I rotate a UIView the edges become distorted 如何知道 iOS 应用何时响应 - How to know when iOS app becomes responsive 在iOS 8中输入视频时旋转 - Rotate when enters a video in iOS 8 iOS UIView背景在移动时变得透明 - iOS UIView Background Becomes Transparent When Moved iOS当应用程序变为活动状态时,始终位于“首页” - iOS Always be on Startpage when App becomes active 当我尝试从React Native iOS应用程序共享我的应用程序URL时,应用程序变得无响应 - App becomes unresponsive when I tried to share my app url from react native iOS app 当我从ios中的“详细信息”页面推回到“ TableList”页面时,TableList崩溃 - TableList becomes crashing when i push back from Details page to TableList page in ios
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM