[Android] VideoPlayer: fix switch to audio mode

Thomas Guillem git at videolan.org
Thu Apr 16 17:20:19 CEST 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Apr 16 17:13:27 2015 +0200| [fe9bc13170b6392309ece4c3b1abc686751b3658] | committer: Thomas Guillem

VideoPlayer: fix switch to audio mode

- Don't switch to audio mode if there is no audio tracks.

- Wait a little before testing if there is no video tracks since it may come
  later.

Fixes #14403

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=fe9bc13170b6392309ece4c3b1abc686751b3658
---

 .../videolan/vlc/gui/video/VideoPlayerActivity.java   |   17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 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 d9d1c62..036bc57 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -191,6 +191,7 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
     private static final int AUDIO_SERVICE_CONNECTION_FAILED = 6;
     private static final int END_DELAY_STATE = 7;
     private static final int RESET_BACK_LOCK = 8;
+    private static final int CHECK_VIDEO_TRACKS = 9;
     private boolean mDragging;
     private boolean mShowing;
     private DelayState mDelay = DelayState.OFF;
@@ -1462,12 +1463,11 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
                     // avoid useless error logs
                     break;
                 case EventHandler.MediaPlayerESAdded:
-                    if (!activity.mHasMenu && activity.mLibVLC.getVideoTracksCount() < 1) {
-                        Log.i(TAG, "No video track, open in audio mode");
-                        activity.switchToAudioMode(true);
-                    }
-                    // no break here, we want to invalidate tracks
                 case EventHandler.MediaPlayerESDeleted:
+                    if (!activity.mHasMenu) {
+                        activity.mHandler.removeMessages(CHECK_VIDEO_TRACKS);
+                        activity.mHandler.sendEmptyMessageDelayed(CHECK_VIDEO_TRACKS, 1000);
+                    }
                     activity.invalidateESTracks(msg.getData().getInt("data"));
                     break;
                 default:
@@ -1521,6 +1521,13 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
                     break;
                 case RESET_BACK_LOCK:
                     activity.mLockBackButton = true;
+                    break;
+                case CHECK_VIDEO_TRACKS:
+                    if (activity.mLibVLC.getVideoTracksCount() < 1 && activity.mLibVLC.getAudioTracksCount() > 0) {
+                        Log.i(TAG, "No video track, open in audio mode");
+                        activity.switchToAudioMode(true);
+                    }
+                    break;
             }
         }
     };



More information about the Android mailing list