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 // using parentFragmentManager is important here
shareDialog.show(parentFragmentManager, ShareDialog::class.java.name) shareDialog.show(parentFragmentManager, ShareDialog::class.java.name)
} }
context?.getString(R.string.play_next) -> {
PlayingQueue.playNext(videoId)
}
context?.getString(R.string.add_to_queue) -> { context?.getString(R.string.add_to_queue) -> {
PlayingQueue.add(videoId) PlayingQueue.add(videoId)
} }

View File

@ -2,6 +2,7 @@ package com.github.libretube.util
object PlayingQueue { object PlayingQueue {
val queue = mutableListOf<String>() val queue = mutableListOf<String>()
val currentVideoId: String? = null
fun clear() { fun clear() {
queue.clear() queue.clear()
@ -11,10 +12,16 @@ object PlayingQueue {
queue.add(videoId) queue.add(videoId)
} }
fun playNext(currentVideoId: String, nextVideoId: String) { fun playNext(nextVideoId: String) {
queue.add( queue.add(
queue.indexOf(currentVideoId), queue.indexOf(currentVideoId),
nextVideoId 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="backup_customInstances">Custom Instances</string>
<string name="save_feed">Load feed in background</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="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 --> <!-- Notification channel strings -->
<string name="download_channel_name">Download Service</string> <string name="download_channel_name">Download Service</string>