[Android] AudioPlayer: switch to video automatically

Thomas Guillem git at videolan.org
Fri Jul 10 19:20:35 CEST 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Jul 10 19:19:51 2015 +0200| [e9932e38f9bfc8f2707d6d9416bc2493c634ef33] | committer: Thomas Guillem

AudioPlayer: switch to video automatically

If the playing file is a video, switch to video mode, do it only one time.

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

 .../src/org/videolan/vlc/gui/audio/AudioPlayer.java      |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
index 9afcdc9..3df668a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -94,6 +94,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
 
     private boolean mShowRemainingTime = false;
     private boolean mPreviewingSeek = false;
+    private boolean mSwitchedToVideo = true;
 
     private AudioPlaylistAdapter mSongsListAdapter;
 
@@ -167,6 +168,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
             public void onClick(View v) {
                 if (mService != null) {
                     mService.switchToVideo();
+                    mSwitchedToVideo = true;
                 }
             }
         });
@@ -328,6 +330,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
             if (mSettings.getBoolean(PreferencesActivity.VIDEO_RESTORE, false)){
                 Util.commitPreferences(mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, false));
                 mService.switchToVideo();
+                mSwitchedToVideo = true;
                 return;
             } else
                 show();
@@ -416,6 +419,17 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
 
     @Override
     public void onMediaPlayerEvent(MediaPlayer.Event event) {
+        switch (event.type) {
+            case MediaPlayer.Event.Opening:
+                mSwitchedToVideo = false;
+                break;
+            case MediaPlayer.Event.ESAdded:
+                if (!mSwitchedToVideo && event.getEsChangedType() == Media.Track.Type.Video) {
+                    mService.switchToVideo();
+                    mSwitchedToVideo = true;
+                }
+                break;
+        }
     }
 
     private void updateList() {



More information about the Android mailing list