Repository navigation
feat(auto): synced lyrics on Android Auto (+ fix songs stuck buffering) - #64
Merged
vortexapps67 merged 3 commits intoNov 17, 2026
Conversation
Android Auto only renders what the media session publishes, so lyrics
reach the car two ways:
- Now playing: while the phone is in car mode, the current synced line
replaces the title row and the song moves to the smaller row. Long
lines are split across both rows so they don't get cut off. The
in-app player and the phone notification outside the car are
unchanged.
- Lyrics tab: a new root tab lists a window of lines around the current
one (marked with a note and a play icon, next line as subtitle).
Tapping a line seeks to it without touching the queue. Refreshes are
coalesced to at most one every 500 ms. If the car can't show five
tabs, Artists gives way.
Both can be turned off in Settings > Content > Lyrics
("Lyrics on Android Auto"), on by default.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tested on the Desktop Head Unit with a phone running Android Auto:
- Detect the car by the Android Auto controller connecting to the session.
Current Android Auto no longer puts the phone in car mode, so the lyric
line never showed in a real car.
- Lyrics tab: one row, the current line as title and the next line as the
subtitle (Android Auto draws it smaller and dimmer). No icon or marker.
- In the car the radio button becomes a lyrics on/off button; the phone
keeps the radio button.
- Read the setting before the first tab request, and refresh the tabs when
it changes, so the Lyrics tab doesn't go missing on a cold start.
- Status rows ("Nothing is playing") aren't playable, so Android Auto
doesn't offer them as "For you" suggestions.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With a signed-in account, every stream resolution also fetches WEB_REMIX metadata, which generates a PoToken in a WebView. When that WebView stops answering (seen when Android Auto starts the service with no activity), the song stayed in BUFFERING forever, and because the generator holds webPoTokenGenLock, every later song got stuck too until the app was restarted. - PoTokenGenerator: limit generation to 10 s; after a timeout the next call starts from a fresh WebView. - YTPlayerUtils: coroutineScope waited for the metadata job even after its 400 ms timeout dropped the result. Cancel it instead, and make the PoToken call interruptible so the cancel takes effect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Synced lyrics on Android Auto. A media app can't draw its own screen in the car (Android Auto only renders what the media session publishes), so the lyrics reach the car through the parts it does render:
1. Now playing line. In the car, the current synced line replaces the title row (the biggest text on the screen) and the song moves to the smaller row below. Lines over ~32 characters are split across both rows so they don't get cut off. The same line shows in the split-screen media card next to Maps, where it reads nicely as two lines.
2. Lyrics tab. A new root tab with one row: the current line as the title and the next line as the subtitle, which Android Auto draws smaller and dimmer. Tapping it seeks to the start of the line (the queue is left alone). Refreshes are coalesced to one every 500 ms since Android Auto throttles browse updates. If the car allows fewer than five tabs, Artists gives way so Lyrics fits (Songs, Albums, Playlists, Lyrics).
3. Lyrics on/off button in the car. In the car, the last now playing button (Start radio) becomes a lyrics toggle; the phone notification keeps the radio button. The same setting is in Settings → Content → Lyrics → "Lyrics on Android Auto" (on by default).
Everything above keeps working while driving (checked with the DHU's
restrict all).Also fixed: songs stuck in buffering
Found while testing in the car, but it isn't specific to Android Auto. With a signed-in account, every stream resolution also fetches WEB_REMIX metadata, which generates a PoToken in a WebView. When that WebView stops answering (it happened reliably when Android Auto started the service with no activity), the song stayed in
BUFFERINGat 0:00 forever. Because the generator holdswebPoTokenGenLock, every later song got stuck too, until the app was restarted. This looks like the "music sometimes doesn't play / gets stuck" reports.PoTokenGenerator: generation is limited to 10 s; after a timeout the next call starts from a fresh WebView.YTPlayerUtils:coroutineScopestill waited for the metadata job after its 400 ms timeout had dropped the result. It's cancelled now, and the PoToken call is interruptible so the cancel takes effect.This is a separate commit (
fix(playback): ...), so it's easy to pick or drop on its own.How
LyricsMetadataPlayer: aForwardingPlayerhanded only to the media session. It overridesgetMediaMetadata()to carry the line and firesonMediaMetadataChangedto the session's listeners when the line changes. The in-app UI and the phone notification outside the car keep the real metadata. It's recreated on the crossfade player swap.AndroidAutoLyrics: loads synced lyrics for the current song from the existinglyricstable, follows the position withLyricsUtils.findCurrentLineIndex, and knows when it's in the car: the Android Auto controller (com.google.android.projection.gearhead) is connected to the session, or car UI mode /FEATURE_AUTOMOTIVE. Current Android Auto no longer puts the phone in car mode, so the controller check is what works in real cars. Unsynced lyrics are skipped since there's no current line to follow.MediaLibrarySessionCallback: thelyricsroot tab and its row; a tap (lyrics/<songId>/<timeMs>) seeks inonSetMediaItemsand returns a failed future so the queue isn't replaced. Status rows ("Nothing is playing") aren't playable, so Android Auto doesn't offer them as "For you" suggestions. The setting is read before the first tab request and the tabs are refreshed when it changes, so the Lyrics tab doesn't go missing on a cold start.Testing
Built
arm64GmsReleaseand tested on a Samsung S23 Ultra (Android 16, Android Auto 17.9) connected to the Desktop Head Unit:restrict all): line, card and tab keep working.🤖 Generated with Claude Code