Respect queue settings when using player controls

This commit is contained in:
Bnyro 2023-06-11 14:50:05 +02:00
parent d96acd85fc
commit dfef007bd9

View File

@ -42,18 +42,17 @@ object PlayingQueue {
) )
} }
// return the next item, or if repeating enabled, the first one of the queue
fun getNext(): String? = queue.getOrNull(currentIndex() + 1)?.url?.toID() fun getNext(): String? = queue.getOrNull(currentIndex() + 1)?.url?.toID()
?: queue.firstOrNull()?.url?.toID()?.takeIf { repeatQueue } ?: queue.firstOrNull()?.url?.toID()?.takeIf { repeatQueue }
// return the previous item, or if repeating enabled, the last one of the queue
fun getPrev(): String? = queue.getOrNull(currentIndex() - 1)?.url?.toID() fun getPrev(): String? = queue.getOrNull(currentIndex() - 1)?.url?.toID()
?: queue.lastOrNull()?.url?.toID()?.takeIf { repeatQueue }
fun hasPrev(): Boolean { fun hasPrev() = getPrev() != null
return currentIndex() > 0
}
fun hasNext(): Boolean { fun hasNext() = getNext() != null
return currentIndex() + 1 < size()
}
fun updateCurrent(streamItem: StreamItem) { fun updateCurrent(streamItem: StreamItem) {
currentStream = streamItem currentStream = streamItem