Skip to content

Commit

Permalink
Fix inconsistent seek (to previous) behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
25huizengek1 committed Sep 17, 2024
1 parent cde432f commit 4923af2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ fun Thumbnail(
binder?.player?.forceSeekToNext()
},
onSwipeRight = {
binder?.player?.seekToDefaultPosition()
binder?.player?.forceSeekToPrevious()
binder?.player?.forceSeekToPrevious(seekToStart = false)
}
),
contentAlignment = Alignment.Center,
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/kotlin/app/vitune/android/utils/Player.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ fun Player.forcePlayAtIndex(
fun Player.forcePlayFromBeginning(items: List<MediaItem>) = forcePlayAtIndex(items, 0)

fun Player.forceSeekToPrevious(
hideExplicit: Boolean = AppearancePreferences.hideExplicit
hideExplicit: Boolean = AppearancePreferences.hideExplicit,
seekToStart: Boolean = true
): Unit = when {
seekToStart && currentPosition > maxSeekToPreviousPosition -> seekToPrevious()
hideExplicit -> {
if (mediaItemCount > 1) {
var i = currentMediaItemIndex - 1
Expand All @@ -80,7 +82,6 @@ fun Player.forceSeekToPrevious(
}
hasPreviousMediaItem() -> seekToPreviousMediaItem()
mediaItemCount > 0 -> seekTo(mediaItemCount - 1, C.TIME_UNSET)
currentPosition > maxSeekToPreviousPosition -> seekToPrevious()
else -> {}
}

Expand Down

0 comments on commit 4923af2

Please sign in to comment.