playing queue improvements

This commit is contained in:
Bnyro 2022-09-19 20:13:25 +02:00
parent d99386bbc2
commit 60b49f2120
3 changed files with 12 additions and 1 deletions

View File

@ -89,6 +89,9 @@ class VideoOptionsBottomSheet(
// using parentFragmentManager is important here
shareDialog.show(parentFragmentManager, ShareDialog::class.java.name)
}
context?.getString(R.string.play_next) -> {
PlayingQueue.playNext(videoId)
}
context?.getString(R.string.add_to_queue) -> {
PlayingQueue.add(videoId)
}

View File

@ -2,6 +2,7 @@ package com.github.libretube.util
object PlayingQueue {
val queue = mutableListOf<String>()
val currentVideoId: String? = null
fun clear() {
queue.clear()
@ -11,10 +12,16 @@ object PlayingQueue {
queue.add(videoId)
}
fun playNext(currentVideoId: String, nextVideoId: String) {
fun playNext(nextVideoId: String) {
queue.add(
queue.indexOf(currentVideoId),
nextVideoId
)
}
fun getNext(): String? {
val currentIndex = queue.indexOf(currentVideoId)
return if (currentIndex > queue.size) null
else queue[currentIndex + 1]
}
}

View File

@ -329,6 +329,7 @@
<string name="backup_customInstances">Custom Instances</string>
<string name="save_feed">Load feed in background</string>
<string name="save_feed_summary">Load the subscription feed in the background and prevent it from being auto-refreshed.</string>
<string name="play_next">Play next</string>
<!-- Notification channel strings -->
<string name="download_channel_name">Download Service</string>