diff --git a/android/app/src/main/java/com/audiobookshelf/app/player/MediaSessionCallback.kt b/android/app/src/main/java/com/audiobookshelf/app/player/MediaSessionCallback.kt index cc2ba1f6..f7e3c89a 100644 --- a/android/app/src/main/java/com/audiobookshelf/app/player/MediaSessionCallback.kt +++ b/android/app/src/main/java/com/audiobookshelf/app/player/MediaSessionCallback.kt @@ -86,7 +86,8 @@ class MediaSessionCallback(var playerNotificationService:PlayerNotificationServi } override fun onSeekTo(pos: Long) { - playerNotificationService.seekPlayer(pos) + val currentTrackStartOffset = playerNotificationService.getCurrentTrackStartOffsetMs() + playerNotificationService.seekPlayer(currentTrackStartOffset + pos) } private fun onChangeSpeed() { diff --git a/android/app/src/main/java/com/audiobookshelf/app/player/PlayerNotificationService.kt b/android/app/src/main/java/com/audiobookshelf/app/player/PlayerNotificationService.kt index 07a2373a..16e0f19b 100644 --- a/android/app/src/main/java/com/audiobookshelf/app/player/PlayerNotificationService.kt +++ b/android/app/src/main/java/com/audiobookshelf/app/player/PlayerNotificationService.kt @@ -652,16 +652,20 @@ class PlayerNotificationService : MediaBrowserServiceCompat() { } } - fun getCurrentTime() : Long { + fun getCurrentTrackStartOffsetMs() : Long { return if (currentPlayer.mediaItemCount > 1) { val windowIndex = currentPlayer.currentMediaItemIndex val currentTrackStartOffset = currentPlaybackSession?.getTrackStartOffsetMs(windowIndex) ?: 0L - currentPlayer.currentPosition + currentTrackStartOffset + currentTrackStartOffset } else { - currentPlayer.currentPosition + 0 } } + fun getCurrentTime() : Long { + return currentPlayer.currentPosition + getCurrentTrackStartOffsetMs() + } + fun getCurrentTimeSeconds() : Double { return getCurrentTime() / 1000.0 }