mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-16 04:52:39 +02:00
Implemented last queue saving.
This commit is contained in:
@@ -114,6 +114,12 @@ class StatePlayer {
|
|||||||
var currentVideo: IPlatformVideo? = null
|
var currentVideo: IPlatformVideo? = null
|
||||||
private set;
|
private set;
|
||||||
|
|
||||||
|
init {
|
||||||
|
onQueueChanged.subscribe {
|
||||||
|
updateLastQueue()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun setCurrentlyPlaying(video: IPlatformVideo?) {
|
fun setCurrentlyPlaying(video: IPlatformVideo?) {
|
||||||
currentVideo = video;
|
currentVideo = video;
|
||||||
}
|
}
|
||||||
@@ -384,6 +390,22 @@ class StatePlayer {
|
|||||||
setQueuePosition(video);
|
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) {
|
fun setQueuePosition(video: IPlatformVideo) {
|
||||||
synchronized(_queue) {
|
synchronized(_queue) {
|
||||||
if (getCurrentQueueItem() == video) {
|
if (getCurrentQueueItem() == video) {
|
||||||
|
|||||||
@@ -394,6 +394,7 @@ class StatePlaylists {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val TAG = "StatePlaylists";
|
val TAG = "StatePlaylists";
|
||||||
|
val LAST_QUEUE_PLAYLIST_ID = "a70a3287-45dd-4227-832c-6ecde7fb1bf6"
|
||||||
private var _instance : StatePlaylists? = null;
|
private var _instance : StatePlaylists? = null;
|
||||||
private var _lockObject = Object()
|
private var _lockObject = Object()
|
||||||
val instance : StatePlaylists
|
val instance : StatePlaylists
|
||||||
|
|||||||
Reference in New Issue
Block a user