[Android] Audio Player : Allow seek action on the last and first playlist song

Alexandre Perraud git at videolan.org
Thu Oct 22 18:42:27 CEST 2015


vlc-ports/android | branch: master | Alexandre Perraud <4leyx4ndre at gmail.com> | Thu Oct 22 18:41:08 2015 +0200| [954b35fabd56daba1ac0457dfb231c00b34e0ba0] | committer: Alexandre Perraud

Audio Player : Allow seek action on the last and first playlist song

fix #15058

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

 vlc-android/res/values/strings.xml                 |    2 ++
 .../org/videolan/vlc/gui/audio/AudioPlayer.java    |   21 ++++++++++----------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 20d1b08..ebcbff26 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -106,6 +106,8 @@
     <string name="previous">Previous</string>
     <string name="stop">Stop</string>
     <string name="next">Next</string>
+    <string name="firstsong">First song of the playlist</string>
+    <string name="lastsong">Last song of the playlist</string>
 
     <string name="locked">Locked</string>
     <string name="unlocked">Unlocked</string>
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 ebcfdba..bf1ffdb 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -27,6 +27,7 @@ import android.media.AudioManager;
 import android.os.Bundle;
 import android.os.Handler;
 import android.preference.PreferenceManager;
+import android.support.design.widget.Snackbar;
 import android.support.v4.app.FragmentActivity;
 import android.support.v4.app.FragmentManager;
 import android.util.Log;
@@ -381,14 +382,6 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
 
         final List<String> mediaLocations = mService.getMediaLocations();
         mShuffle.setVisibility(mediaLocations != null && mediaLocations.size() > 2 ? View.VISIBLE : View.INVISIBLE);
-        if (mService.hasNext())
-            mNext.setVisibility(ImageButton.VISIBLE);
-        else
-            mNext.setVisibility(ImageButton.INVISIBLE);
-        if (mService.hasPrevious())
-            mPrevious.setVisibility(ImageButton.VISIBLE);
-        else
-            mPrevious.setVisibility(ImageButton.INVISIBLE);
         mTimeline.setOnSeekBarChangeListener(mTimelineListner);
 
         updateList();
@@ -514,13 +507,21 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
     }
 
     public void onNextClick(View view) {
-        if (mService != null)
+        if (mService == null)
+            return;
+        if (mService.hasNext())
             mService.next();
+        else
+            Snackbar.make(getView(), R.string.lastsong, Snackbar.LENGTH_SHORT).show();
     }
 
     public void onPreviousClick(View view) {
-        if (mService != null)
+        if (mService == null)
+            return;
+        if (mService.hasPrevious())
             mService.previous();
+        else
+            Snackbar.make(getView(), R.string.firstsong, Snackbar.LENGTH_SHORT).show();
     }
 
     public void onRepeatClick(View view) {



More information about the Android mailing list