如何在启用全屏模式时以横向模式保持视频播放?

时间:2015-08-06 12:23:23

标签: ios objective-c iphone xcode ipad

我正在制作一个应用程序,我正在从url播放视频。我正在小窗口中显示该视频。我正在以横向模式播放视频。请看快照。Image Here

现在我有两个问题

  • 视频上的UI控件不会缩小为小尺寸。
  • 当我以全屏模式观看视频时,它会自动旋转到纵向模式。因此,只有在全屏模式下才可以以横向模式播放视频。

播放视频的代码

NSURL *fileURL = [NSURL URLWithString:@"http://www.w3schools.com/html/movie.mp4"];
    self.moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
    CGRect movieFrame;
    movieFrame.size = self.videoView.frame.size;
    [self.moviePlayerController.view setFrame:movieFrame];
    [self.moviePlayerController.view setTranslatesAutoresizingMaskIntoConstraints:NO];
    [self.videoView addSubview:self.moviePlayerController.view];
    [self.videoView bringSubviewToFront:self.moviePlayerController.view];
    [self.videoView addConstraint:[NSLayoutConstraint constraintWithItem:self.moviePlayerController.view
                                                          attribute:NSLayoutAttributeBottom
                                                          relatedBy:NSLayoutRelationEqual
                                                             toItem:self.videoView
                                                          attribute:NSLayoutAttributeBottom
                                                         multiplier:1.0
                                                           constant:0.0]];
        [self.videoView addConstraint:[NSLayoutConstraint constraintWithItem:self.moviePlayerController.view
                                                          attribute:NSLayoutAttributeTrailing
                                                          relatedBy:NSLayoutRelationEqual
                                                             toItem:self.videoView
                                                          attribute:NSLayoutAttributeTrailing
                                                         multiplier:1.0
                                                           constant:0.0]];
    [self.videoView addConstraint:[NSLayoutConstraint constraintWithItem:self.moviePlayerController.view
                                                               attribute:NSLayoutAttributeLeading
                                                               relatedBy:NSLayoutRelationEqual
                                                                  toItem:self.videoView
                                                               attribute:NSLayoutAttributeLeading
                                                              multiplier:1.0
                                                                constant:0.0]];
        [self.videoView addConstraint:[NSLayoutConstraint constraintWithItem:self.moviePlayerController.view
                                                               attribute:NSLayoutAttributeTop
                                                               relatedBy:NSLayoutRelationEqual
                                                                  toItem:self.videoView
                                                               attribute:NSLayoutAttributeTop
                                                              multiplier:1.0
                                                                constant:0.0]];
 [self.moviePlayerController play];

0 个答案:

没有答案