Implemented last queue saving.

This commit is contained in:
Koen J
2025-11-15 12:41:22 +01:00
parent fc9d5eeb27
commit 727f977672
2 changed files with 23 additions and 0 deletions
@@ -114,6 +114,12 @@ class StatePlayer {
var currentVideo: IPlatformVideo? = null
private set;
init {
onQueueChanged.subscribe {
updateLastQueue()
}
}
fun setCurrentlyPlaying(video: IPlatformVideo?) {
currentVideo = video;
}
@@ -384,6 +390,22 @@ class StatePlayer {
setQueuePosition(video);
}
}
fun updateLastQueue() {
val queueVideos = synchronized(_queue) {
if (!_queue.isEmpty()) {
return@synchronized _queue.map { SerializedPlatformVideo.fromVideo(it) }.toList()
}
return@synchronized null
}
if (queueVideos != null) {
val playlist = Playlist("Last Queue", queueVideos);
playlist.id = StatePlaylists.LAST_QUEUE_PLAYLIST_ID
StatePlaylists.instance.createOrUpdatePlaylist(playlist, isUserInteraction = false)
}
}
fun setQueuePosition(video: IPlatformVideo) {
synchronized(_queue) {
if (getCurrentQueueItem() == video) {
@@ -394,6 +394,7 @@ class StatePlaylists {
companion object {
val TAG = "StatePlaylists";
val LAST_QUEUE_PLAYLIST_ID = "a70a3287-45dd-4227-832c-6ecde7fb1bf6"
private var _instance : StatePlaylists? = null;
private var _lockObject = Object()
val instance : StatePlaylists