Skip to content

feat(auto): synced lyrics on Android Auto (+ fix songs stuck buffering) - #64

Merged
vortexapps67 merged 3 commits into
vortexapps67:mainfrom
subscriptions-dot:feature/android-auto-lyrics
Nov 17, 2026
Merged

vortexapps67 merged 3 commits into
vortexapps67:mainfrom
subscriptions-dot:feature/android-auto-lyrics

Conversation

@subscriptions-dot

@subscriptions-dot subscriptions-dot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

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 BUFFERING at 0:00 forever. Because the generator holds webPoTokenGenLock, 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: coroutineScope still 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: a ForwardingPlayer handed only to the media session. It overrides getMediaMetadata() to carry the line and fires onMediaMetadataChanged to 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 existing lyrics table, follows the position with LyricsUtils.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: the lyrics root tab and its row; a tap (lyrics/<songId>/<timeMs>) seeks in onSetMediaItems and 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 arm64GmsRelease and tested on a Samsung S23 Ultra (Android 16, Android Auto 17.9) connected to the Desktop Head Unit:

  • Now playing: the line follows the song for Hindi (Devanagari), Punjabi (Gurmukhi) and English lyrics; long lines split across both rows; the Maps split-screen card shows the line.
  • Lyrics tab: current + dimmer next line, tap seeks, list follows playback, tab present after a cold start.
  • Lyrics button: off brings the song title back and removes the tab; on brings the line back right away.
  • Driving restrictions (restrict all): line, card and tab keep working.
  • Playback fix: before, starting playback from the car with the app closed left songs stuck at 0:00 until a restart. After, the same steps play within a few seconds, and skipping several songs in a row plays each one.
  • Also checked on an API 35 emulator with Google's Media Controller Test. No crashes in logcat.

🤖 Generated with Claude Code

subscriptions-dot and others added 3 commits November 2, 2026 12:29
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>
@subscriptions-dot subscriptions-dot changed the title feat(auto): show synced lyrics on Android Auto feat(auto): synced lyrics on Android Auto (+ fix songs stuck buffering) Nov 3, 2026
@vortexapps67
vortexapps67 merged commit fb72e63 into vortexapps67:main Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants