[Android] Fix the current song saved when the playqueue is finished
Nicolas Pomepuy
git at videolan.org
Tue Jul 20 12:22:14 UTC 2021
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Jul 19 09:37:09 2021 +0200| [046441c777849c09db530899adddf7978f3b18f0] | committer: Nicolas Pomepuy
Fix the current song saved when the playqueue is finished
Fixes #2101
> https://code.videolan.org/videolan/vlc-android/commit/046441c777849c09db530899adddf7978f3b18f0
---
.../src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt | 3 ++-
.../vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 5 +++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
index 661e43737..66a38e57c 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
@@ -52,6 +52,7 @@ import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.delay
import org.videolan.libvlc.util.AndroidUtil
import org.videolan.medialibrary.interfaces.Medialibrary
+import org.videolan.resources.KEY_CURRENT_AUDIO
import org.videolan.resources.util.getFromMl
import org.videolan.resources.util.startMedialibrary
import org.videolan.tools.*
@@ -416,7 +417,7 @@ open class AudioPlayerContainerActivity : BaseActivity() {
fun proposeCard() = lifecycleScope.launchWhenStarted {
delay(1000L)
if (PlaylistManager.showAudioPlayer.value == true) return at launchWhenStarted
- val song = settings.getString("current_song", null) ?: return at launchWhenStarted
+ val song = settings.getString(KEY_CURRENT_AUDIO, null) ?: return at launchWhenStarted
val media = getFromMl { getMedia(song.toUri()) } ?: return at launchWhenStarted
val title = media.title
resumeCard = Snackbar.make(appBarLayout, getString(R.string.resume_card_message, title), Snackbar.LENGTH_LONG)
diff --git a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index 722ac78bb..90dc6a7cf 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -716,6 +716,11 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
if (!audio) {
putFloat(VIDEO_SPEED, player.getRate())
}
+ //we reached the end. The next proposed media should be the first of the list
+ if (reset) {
+ val media = getMediaList()[0]
+ putString(KEY_CURRENT_AUDIO, media.location)
+ }
}
}
More information about the Android
mailing list