[Android] Reset current playlist to beginning onend reached

Geoffrey Métais git at videolan.org
Fri Oct 27 11:38:31 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Oct 27 11:19:42 2017 +0200| [647f82b4767142d8bdb1edb0f13f4426a0d44cd1] | committer: Geoffrey Métais

Reset current playlist to beginning onend reached

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

 vlc-android/src/org/videolan/vlc/PlaybackService.java | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index a52851509..de868f6c8 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -643,6 +643,8 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
                     executeUpdateProgress();
                     previousMediaStats = mMediaPlayer.getMedia().getStats();
                     determinePrevAndNextIndices(true);
+                    if (mNextIndex == -1)
+                        savePosition(true);
                     next();
                     break;
                 case MediaPlayer.Event.EncounteredError:
@@ -1643,14 +1645,18 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
     }
 
     private synchronized void savePosition() {
+        savePosition(false);
+    }
+
+    private synchronized void savePosition(boolean reset) {
         if (!hasMedia())
             return;
         final SharedPreferences.Editor editor = mSettings.edit();
         boolean audio = !canSwitchToVideo() && mMediaList.isAudioList();
         editor.putBoolean(audio ? "audio_shuffling" : "media_shuffling", mShuffling);
         editor.putInt(audio ? "audio_repeating" : "media_repeating", mRepeating);
-        editor.putInt(audio ? "position_in_audio_list" : "position_in_media_list", mCurrentIndex);
-        editor.putLong(audio ? "position_in_song" : "position_in_media", mMediaPlayer.getTime());
+        editor.putInt(audio ? "position_in_audio_list" : "position_in_media_list", reset ? 0 : mCurrentIndex);
+        editor.putLong(audio ? "position_in_song" : "position_in_media", reset ? 0L : mMediaPlayer.getTime());
         if (!audio) {
             editor.putBoolean(PreferencesActivity.VIDEO_PAUSED, !isPlaying());
             editor.putFloat(PreferencesActivity.VIDEO_SPEED, getRate());



More information about the Android mailing list