[Android] Videoplayer: FIx NPE with defective presentation

Geoffrey Métais git at videolan.org
Thu Feb 1 13:46:53 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Feb  1 13:46:26 2018 +0100| [59ded1fa63d4762a54fcdb8daf7b0ceeb8d17727] | committer: Geoffrey Métais

Videoplayer: FIx NPE with defective presentation

> https://code.videolan.org/videolan/vlc-android/commit/59ded1fa63d4762a54fcdb8daf7b0ceeb8d17727
---

 .../src/org/videolan/vlc/gui/video/DisplayManager.kt     |  1 +
 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java  | 16 +++++-----------
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/DisplayManager.kt b/vlc-android/src/org/videolan/vlc/gui/video/DisplayManager.kt
index c24bb0bc9..901032ce1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/DisplayManager.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/DisplayManager.kt
@@ -96,6 +96,7 @@ class DisplayManager(private val activity: Activity, cloneMode: Boolean) : Rende
                 return presentation
             } catch (ex: WindowManager.InvalidDisplayException) {
                 if (BuildConfig.DEBUG) Log.w(TAG, "Couldn't show presentation!  Display was removed in " + "the meantime.", ex)
+                presentationDisplayId = -1
             }
         } else if (BuildConfig.DEBUG) Log.i(TAG, "No secondary display detected")
         return null
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 4f6a28429..6fe551e96 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -785,17 +785,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             } else
                 vlcVout.detachViews();
         }
-        if (mDisplayManager.isPrimary()) {
-            vlcVout.setVideoView(mSurfaceView);
-            vlcVout.setSubtitlesView(mSubtitlesSurfaceView);
-            vlcVout.addCallback(this);
-            vlcVout.attachViews(this);
-        } else if (mDisplayManager.getDisplayType() == DisplayManager.DisplayType.PRESENTATION) {
-            vlcVout.setVideoView(mDisplayManager.getPresentation().getSurfaceView());
-            vlcVout.setSubtitlesView(mDisplayManager.getPresentation().getSubtitlesSurfaceView());
-            vlcVout.addCallback(this);
-            vlcVout.attachViews(this);
-        }
+        final DisplayManager.SecondaryDisplay sd = mDisplayManager.getPresentation();
+        vlcVout.setVideoView(sd != null ? sd.getSurfaceView() : mSurfaceView);
+        vlcVout.setSubtitlesView(sd != null ? sd.getSubtitlesSurfaceView() : mSubtitlesSurfaceView);
+        vlcVout.addCallback(this);
+        vlcVout.attachViews(this);
         mService.setVideoTrackEnabled(true);
 
         initUI();



More information about the Android mailing list