From c93d0c013f25422b4ebd1fa613a5b146703ec79f Mon Sep 17 00:00:00 2001 From: jetracer <38738952+jetracer@users.noreply.github.com> Date: Thu, 9 Jul 2026 05:00:22 -0400 Subject: [PATCH] Fix Android Auto seek buttons doing nothing for car-initiated playback (#466) Two issues prevented the head unit seek controls from working: 1. Books started from the Android Auto browse screen never populated MediaRepository's playingBook state, which is only set by the phone UI flow. Since rewind/forward/previousTrack/nextTrack all bail out silently on a null playingBook, every seek button on the head unit was a no-op while pause kept working (it bypasses MediaRepository). onSetMediaItems now registers the fetched book with MediaRepository. 2. The rewind/forward buttons were assigned to SLOT_OVERFLOW, leaving the primary back/forward slots to chapter navigation. Swapped so the configurable rewind/forward occupy the primary slots, matching audiobook app conventions, with chapter navigation in the overflow. Verified end-to-end on the Desktop Head Unit: commands confirmed arriving via logcat and seeks now applied for books started from the car screen. Co-authored-by: Claude Fable 5 --- .../lissen/playback/MediaLibrarySessionCallback.kt | 9 +++++---- .../org/grakovne/lissen/playback/MediaRepository.kt | 12 ++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/org/grakovne/lissen/playback/MediaLibrarySessionCallback.kt b/app/src/main/kotlin/org/grakovne/lissen/playback/MediaLibrarySessionCallback.kt index ad5a5f26..b60c4aed 100644 --- a/app/src/main/kotlin/org/grakovne/lissen/playback/MediaLibrarySessionCallback.kt +++ b/app/src/main/kotlin/org/grakovne/lissen/playback/MediaLibrarySessionCallback.kt @@ -113,7 +113,7 @@ class MediaLibrarySessionCallback .setSessionCommand(prevChapterCommand) .setDisplayName("Previous Chapter") .setEnabled(true) - .setSlots(CommandButton.SLOT_BACK) + .setSlots(CommandButton.SLOT_OVERFLOW) .build() val nextChapterButton = @@ -121,7 +121,7 @@ class MediaLibrarySessionCallback .Builder(CommandButton.ICON_NEXT) .setSessionCommand(nextChapterCommand) .setDisplayName("Next Chapter") - .setSlots(CommandButton.SLOT_FORWARD) + .setSlots(CommandButton.SLOT_OVERFLOW) .setEnabled(true) .build() @@ -131,7 +131,7 @@ class MediaLibrarySessionCallback .setSessionCommand(rewindCommand) .setDisplayName("Rewind") .setEnabled(true) - .setSlots(CommandButton.SLOT_OVERFLOW) + .setSlots(CommandButton.SLOT_BACK) .build() val forwardButton = @@ -139,7 +139,7 @@ class MediaLibrarySessionCallback .Builder(CommandButton.ICON_SKIP_FORWARD) .setSessionCommand(forwardCommand) .setDisplayName("Forward") - .setSlots(CommandButton.SLOT_OVERFLOW) + .setSlots(CommandButton.SLOT_FORWARD) .setEnabled(true) .build() @@ -210,6 +210,7 @@ class MediaLibrarySessionCallback preferences.savePlayingItem(it) playbackSynchronizationService.startPlaybackSynchronization(it) } + mediaRepository.registerPlayingBook(it) PlaybackService.bookToChapterMediaItems(it) }, onFailure = { MediaItemsWithStartPosition(emptyList(), 0, 0) }, diff --git a/app/src/main/kotlin/org/grakovne/lissen/playback/MediaRepository.kt b/app/src/main/kotlin/org/grakovne/lissen/playback/MediaRepository.kt index b0938eb1..3fc77697 100644 --- a/app/src/main/kotlin/org/grakovne/lissen/playback/MediaRepository.kt +++ b/app/src/main/kotlin/org/grakovne/lissen/playback/MediaRepository.kt @@ -415,6 +415,18 @@ class MediaRepository _isPlaybackReady.value = false } + fun registerPlayingBook(book: DetailedItem) { + val sameBook = _playingBook.value?.same(book) ?: false + + if (sameBook.not()) { + Timber.d("Registering playing book prepared via media session: ${book.id}") + + _totalPosition.value = book.progress?.currentTime ?: 0.0 + _playingBook.value = book + _isPlaybackReady.value = true + } + } + private fun startPreparingPlayback(book: DetailedItem) { val sameBook = _playingBook.value?.same(book) ?: false