[Android] VideoPlayerActivity: no vout: wait a little before closing activity

Thomas Guillem git at videolan.org
Fri Nov 25 09:48:06 CET 2016


vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Nov 25 09:47:51 2016 +0100| [0792393deb6c6f014722d0bc25742b9d7dc69dea] | committer: Thomas Guillem

VideoPlayerActivity: no vout: wait a little before closing activity

We don't want to close the video player if the vout is restarting.

> https://code.videolan.org/videolan/vlc-android/commit/0792393deb6c6f014722d0bc25742b9d7dc69dea
---

 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java  | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 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 2467818..397325a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1756,16 +1756,24 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         mAlertDialog.show();
     }
 
-    private void handleVout(int voutCount) {
-        final IVLCVout vlcVout = mService.getVLCVout();
-        if (vlcVout.areViewsAttached() && voutCount == 0) {
-            /* Video track lost, open in audio mode */
+    private final Runnable mSwitchAudioRunnable = new Runnable() {
+        @Override
+        public void run() {
             if (mService.hasMedia()) {
                 Log.i(TAG, "Video track lost, switching to audio");
                 mSwitchingView = true;
             }
             exit(RESULT_VIDEO_TRACK_LOST);
         }
+    };
+
+    private void handleVout(int voutCount) {
+        mHandler.removeCallbacks(mSwitchAudioRunnable);
+
+        final IVLCVout vlcVout = mService.getVLCVout();
+        if (vlcVout.areViewsAttached() && voutCount == 0) {
+            mHandler.postDelayed(mSwitchAudioRunnable, 1000);
+        }
     }
 
     public void switchToPopupMode() {



More information about the Android mailing list