Browse Source

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 years ago
parent
commit
63f8a9fb8c
2 changed files with 11 additions and 5 deletions
  1. 4 2
      SharedSources/VLCPlayingExternallyView.swift
  2. 7 3
      Sources/VLCMovieViewController.m

+ 4 - 2
SharedSources/VLCPlayingExternallyView.swift

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

+ 7 - 3
Sources/VLCMovieViewController.m

@@ -1691,11 +1691,15 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
 - (void)showOnDisplay:(UIView *)view
 - (void)showOnDisplay:(UIView *)view
 {
 {
     // if we don't have a renderer we're mirroring and don't want to show the dialog
     // 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];
     [_playingExternalView updateUIWithRendererItem:_vpc.renderer];
-    _vpc.videoOutputView = view;
     _artworkImageView.hidden = displayExternally;
     _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
 - (void)handleExternalScreenDidConnect:(NSNotification *)notification