繁体   English   中英

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

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

我有播放视频的应用程序。 在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

另外取决于水平或垂直视频,我需要旋转它

- (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 );
}

除肖像外,它在所有方向上都很好。 甚至UpsideDown也不错这是屏幕截图

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

ios8中的纵向方向有什么问题?

PS红色视图是mediaPlayer Superview的背景

看起来Apple改变了ios8的旋转方式,现在它仅旋转内容且不影响视图框架。 所以我最终添加了额外的比例转换

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM