[Android] Force previous song on audioplayer swipe

Geoffrey Métais git at videolan.org
Thu Nov 3 11:34:19 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Oct 21 12:05:28 2016 +0200| [aba9809a5a46a889605bfe33503db4f5c4a3d12c] | committer: Geoffrey Métais

Force previous song on audioplayer swipe

Ignore the 2s delay & force previous song instead of getting back to song
beginning

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

 vlc-android/src/org/videolan/vlc/PlaybackService.java          | 10 +++++-----
 vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java    |  6 +++---
 .../videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java   |  2 +-
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java    |  2 +-
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index a23cff0..3be9e4a 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -465,7 +465,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
                 if (hasCurrentMedia())
                     pause();
             } else if (action.equalsIgnoreCase(ACTION_REMOTE_BACKWARD)) {
-                previous();
+                previous(false);
             } else if (action.equalsIgnoreCase(ACTION_REMOTE_STOP) ||
                     action.equalsIgnoreCase(VLCApplication.SLEEP_INTENT)) {
                 stop();
@@ -1100,7 +1100,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
 
         @Override
         public void onSkipToPrevious() {
-            previous();
+            previous(true);
         }
 
         @Override
@@ -1115,7 +1115,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
 
         @Override
         public void onRewind() {
-            previous();
+            previous(false);
         }
     }
 
@@ -1205,9 +1205,9 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
     }
 
     @MainThread
-    public void previous() {
+    public void previous(boolean force) {
         if (hasPrevious() && mCurrentIndex > 0 &&
-                (!mMediaPlayer.isSeekable() || mMediaPlayer.getTime() < 2000l)) {
+                (force || !mMediaPlayer.isSeekable() || mMediaPlayer.getTime() < 2000l)) {
             int size = mMediaList.size();
             mCurrentIndex = mPrevIndex;
             if (mPrevious.size() > 0)
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 2b13643..504bd2f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -505,7 +505,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
         if (mService == null)
             return;
         if (mService.hasPrevious() || mService.isSeekable())
-            mService.previous();
+            mService.previous(false);
         else
             Snackbar.make(getView(), R.string.firstsong, Snackbar.LENGTH_SHORT).show();
     }
@@ -603,7 +603,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
             if (mService == null)
                 return;
             if (position == AudioMediaSwitcherListener.PREVIOUS_MEDIA)
-                mService.previous();
+                mService.previous(true);
             else if (position == AudioMediaSwitcherListener.NEXT_MEDIA)
                 mService.next();
         }
@@ -635,7 +635,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
             if (mService == null)
                 return;
             if (position == AudioMediaSwitcherListener.PREVIOUS_MEDIA)
-                mService.previous();
+                mService.previous(true);
             else if (position == AudioMediaSwitcherListener.NEXT_MEDIA)
                 mService.next();
         }
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
index 1956a0e..070afe1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
@@ -356,7 +356,7 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
 
     private void goPrevious() {
         if (mService != null && mService.hasPrevious()) {
-            mService.previous();
+            mService.previous(false);
         }
     }
 
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 a406093..21f42a1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -2291,7 +2291,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                 mService.next();
                 break;
             case R.id.playlist_previous:
-                mService.previous();
+                mService.previous(false);
                 break;
             case R.id.player_overlay_forward:
                 seekDelta(10000);



More information about the Android mailing list