[Android] Watch for video track lost only on primary display

Geoffrey Métais git at videolan.org
Fri Dec 7 17:02:49 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Dec  7 15:50:04 2018 +0100| [5a8c6fa46b1bb730370362a59f88176fd92b0251] | committer: Geoffrey Métais

Watch for video track lost only on primary display

> https://code.videolan.org/videolan/vlc-android/commit/5a8c6fa46b1bb730370362a59f88176fd92b0251
---

 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

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 04ade2f82..411b845e0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1559,11 +1559,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IPlaybackS
     private final Runnable mSwitchAudioRunnable = new Runnable() {
         @Override
         public void run() {
-            if (mService.hasMedia()) {
+            if (mDisplayManager.isPrimary() && mService.hasMedia() && mService.getVideoTracksCount() == 0) {
                 Log.i(TAG, "Video track lost, switching to audio");
                 mSwitchingView = true;
+                exit(RESULT_VIDEO_TRACK_LOST);
             }
-            exit(RESULT_VIDEO_TRACK_LOST);
         }
     };
 
@@ -1571,11 +1571,18 @@ public class VideoPlayerActivity extends AppCompatActivity implements IPlaybackS
         mHandler.removeCallbacks(mSwitchAudioRunnable);
 
         final IVLCVout vlcVout = mService.getVout();
-        if (vlcVout.areViewsAttached() && voutCount == 0) {
+        if (vlcVout == null) return;
+        if (mDisplayManager.isPrimary() && vlcVout.areViewsAttached() && voutCount == 0) {
             mHandler.postDelayed(mSwitchAudioRunnable, 4000);
         }
     }
 
+    @Override
+    public void recreate() {
+        mHandler.removeCallbacks(mSwitchAudioRunnable);
+        super.recreate();
+    }
+
     public void switchToAudioMode(boolean showUI) {
         if (mService == null) return;
         mSwitchingView = true;



More information about the Android mailing list