Skip to content

Commit

Permalink
Merge pull request #6035 from Bnyro/master
Browse files Browse the repository at this point in the history
fix: button to play previous video doesnt work when repeat enabled
  • Loading branch information
Bnyro authored May 14, 2024
2 parents 916b8a4 + ce9a7c2 commit 0578dda
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions app/src/main/java/com/github/libretube/util/PlayingQueue.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ object PlayingQueue {
)
}

// return the next item, or if repeating enabled, the first one of the queue
// return the next item, or if repeating enabled and no video left, the first one of the queue
fun getNext(): String? {
val nextItem = queue.getOrNull(currentIndex() + 1)
if (nextItem != null) return nextItem.url?.toID()
Expand All @@ -57,17 +57,14 @@ object PlayingQueue {
return null
}

// return the previous item, or if repeating enabled, the last one of the queue
// return the previous item, or if repeating enabled and no video left, the last one of the queue
fun getPrev(): String? {
if (repeatMode != Player.REPEAT_MODE_ONE) {
queue.getOrNull(currentIndex() - 1)?.url?.toID()?.let { return it }
}
val prevItem = queue.getOrNull(currentIndex() - 1)
if (prevItem != null) return prevItem.url?.toID()

return when (repeatMode) {
Player.REPEAT_MODE_ALL -> queue.lastOrNull()?.url?.toID()
Player.REPEAT_MODE_ONE -> currentStream?.url?.toID()
else -> null
}
if (repeatMode == Player.REPEAT_MODE_ALL) return queue.lastOrNull()?.url?.toID()

return null
}

fun hasPrev() = getPrev() != null
Expand Down

0 comments on commit 0578dda

Please sign in to comment.