[Android] properly save/restore position of last audio
Sébastien Toque
git at videolan.org
Wed Sep 16 22:42:56 CEST 2015
vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Wed Sep 16 22:42:47 2015 +0200| [08178bae817c43d91ba032d33807acd7b8fda6fa] | committer: Sébastien Toque
properly save/restore position of last audio
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=08178bae817c43d91ba032d33807acd7b8fda6fa
---
vlc-android/src/org/videolan/vlc/PlaybackService.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 02420b5..7e19b3f 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -965,6 +965,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
@MainThread
public void pause() {
+ savePosition();
mHandler.removeMessages(SHOW_PROGRESS);
// hideNotification(); <-- see event handler
mMediaPlayer.pause();
@@ -1296,6 +1297,8 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
}
private synchronized void savePosition(){
+ if (getCurrentMedia() == null || getCurrentMedia().getType() == MediaWrapper.TYPE_VIDEO)
+ return;
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
editor.putInt("position_in_list", mCurrentIndex);
editor.putLong("position_in_song", mMediaPlayer.getTime());
@@ -1505,6 +1508,9 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
public void load(List<MediaWrapper> mediaList, int position) {
Log.v(TAG, "Loading position " + ((Integer) position).toString() + " in " + mediaList.toString());
+ if (hasCurrentMedia())
+ savePosition();
+
mMediaList.removeEventListener(mListEventListener);
mMediaList.clear();
MediaWrapperList currentMediaList = mMediaList;
More information about the Android
mailing list