Переглянути джерело

VLCMovieViewController: fix displaying on external screen via HDMI

When we refactored we didn't pass the movieView to the external screen when displaying externally
This worked well for chromecast and mirroring but sadly not for attaching an external screen via HDMI
(closes #263)

(cherry picked from commit 10de9b6278bdafe795bf042dc6b8d9813a61c631)
Carola Nitz 7 роки тому
батько
коміт
63f8a9fb8c

+ 4 - 2
SharedSources/VLCPlayingExternallyView.swift

@@ -21,9 +21,8 @@ class VLCPlayingExternallyView: UIView {
     }
     var externalWindow: UIWindow?
 
-    @objc func shouldDisplay(_ show: Bool) {
+    @objc func shouldDisplay(_ show: Bool, movieView: UIView) {
         self.isHidden = !show
-        externalWindow?.isHidden = !show
         if show {
             guard let screen = UIScreen.screens.count > 1 ? UIScreen.screens[1] : nil else {
                 return
@@ -34,11 +33,14 @@ class VLCPlayingExternallyView: UIView {
                 return
             }
             externalWindow.rootViewController = VLCExternalDisplayController()
+            externalWindow.rootViewController?.view.addSubview(movieView)
             externalWindow.screen = screen
             externalWindow.rootViewController?.view.frame = externalWindow.bounds
+            movieView.frame = externalWindow.bounds
         } else {
             externalWindow = nil
         }
+        externalWindow?.isHidden = !show
     }
 
     override func awakeFromNib() {

+ 7 - 3
Sources/VLCMovieViewController.m

@@ -1691,11 +1691,15 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
 - (void)showOnDisplay:(UIView *)view
 {
     // if we don't have a renderer we're mirroring and don't want to show the dialog
-    BOOL displayExternally = _vpc.renderer && view != _movieView;
-    [_playingExternalView shouldDisplay:displayExternally];
+    BOOL displayExternally = view != _movieView;
+    [_playingExternalView shouldDisplay:displayExternally movieView:_movieView];
     [_playingExternalView updateUIWithRendererItem:_vpc.renderer];
-    _vpc.videoOutputView = view;
     _artworkImageView.hidden = displayExternally;
+    if (!displayExternally && _movieView.superview != self.view) {
+        [self.view addSubview:_movieView];
+        [self.view sendSubviewToBack:_movieView];
+        _movieView.frame = self.view.frame;
+    }
 }
 
 - (void)handleExternalScreenDidConnect:(NSNotification *)notification