From 4923af20a392e264c5468c840951fd84d1f8f6e2 Mon Sep 17 00:00:00 2001 From: 25huizengek1 <50515369+25huizengek1@users.noreply.github.com> Date: Tue, 17 Sep 2024 23:58:09 +0200 Subject: [PATCH] Fix inconsistent seek (to previous) behavior --- .../kotlin/app/vitune/android/ui/screens/player/Thumbnail.kt | 3 +-- app/src/main/kotlin/app/vitune/android/utils/Player.kt | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/app/vitune/android/ui/screens/player/Thumbnail.kt b/app/src/main/kotlin/app/vitune/android/ui/screens/player/Thumbnail.kt index 9c8a0d3a83..b97e561423 100644 --- a/app/src/main/kotlin/app/vitune/android/ui/screens/player/Thumbnail.kt +++ b/app/src/main/kotlin/app/vitune/android/ui/screens/player/Thumbnail.kt @@ -135,8 +135,7 @@ fun Thumbnail( binder?.player?.forceSeekToNext() }, onSwipeRight = { - binder?.player?.seekToDefaultPosition() - binder?.player?.forceSeekToPrevious() + binder?.player?.forceSeekToPrevious(seekToStart = false) } ), contentAlignment = Alignment.Center, diff --git a/app/src/main/kotlin/app/vitune/android/utils/Player.kt b/app/src/main/kotlin/app/vitune/android/utils/Player.kt index 2705c3f9d9..d89b2f3435 100644 --- a/app/src/main/kotlin/app/vitune/android/utils/Player.kt +++ b/app/src/main/kotlin/app/vitune/android/utils/Player.kt @@ -63,8 +63,10 @@ fun Player.forcePlayAtIndex( fun Player.forcePlayFromBeginning(items: List) = 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 @@ -80,7 +82,6 @@ fun Player.forceSeekToPrevious( } hasPreviousMediaItem() -> seekToPreviousMediaItem() mediaItemCount > 0 -> seekTo(mediaItemCount - 1, C.TIME_UNSET) - currentPosition > maxSeekToPreviousPosition -> seekToPrevious() else -> {} }