浏览代码

VLCMovieViewController: Fix external display

Closes #679
Soomin Lee 5 年之前
父节点
当前提交
49feff5209
共有 1 个文件被更改,包括 19 次插入0 次删除
  1. 19 0
      Sources/VLCMovieViewController.m

+ 19 - 0
Sources/VLCMovieViewController.m

@@ -1955,11 +1955,30 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
     BOOL displayExternally = view != _movieView;
     [_playingExternalView shouldDisplay:displayExternally movieView:_movieView];
     _artworkImageView.hidden = displayExternally;
+
+    if (displayExternally) {
+        // Adjust constraints for external display
+        UIView *displayView = _playingExternalView.displayView;
+
+        [NSLayoutConstraint activateConstraints:@[
+            [_movieView.leadingAnchor constraintEqualToAnchor:displayView.leadingAnchor],
+            [_movieView.trailingAnchor constraintEqualToAnchor:displayView.trailingAnchor],
+            [_movieView.topAnchor constraintEqualToAnchor:displayView.topAnchor],
+            [_movieView.bottomAnchor constraintEqualToAnchor:displayView.bottomAnchor],
+        ]];
+    }
+
     if (!displayExternally && _movieView.superview != self.view) {
         [self.view addSubview:_movieView];
         [self.view sendSubviewToBack:_movieView];
         _movieView.frame = self.view.frame;
         _artworkImageView.hidden = !_audioOnly;
+
+        // Adjust constraint for local display
+        [self setupMovieViewConstraints];
+        if (@available(iOS 11, *)) {
+            [self adaptMovieViewToNotch];
+        }
     }
 }