Skip to content

feat(carapp,media3): add voice search, transport controls, and car screen like action - #40

Open
valhalla94 wants to merge 2 commits into
maxrave-dev:multiplatformfrom
valhalla94:feat/android-auto-voice-controls
Open

valhalla94 wants to merge 2 commits into
maxrave-dev:multiplatformfrom
valhalla94:feat/android-auto-voice-controls

Conversation

@valhalla94

Copy link
Copy Markdown

What & why

Adds support for Android Auto and assistant-driven voice commands, explicit transport controls, and in-car actions:

  • SimpleMediaSessionCallback:
    • Handles MEDIA_PLAY_FROM_SEARCH queries via onSetMediaItems and onAddMediaItems. Performs online search on YouTube Music and generates an auto-playing radio queue (RDAMVM<id>).
    • Added fallback in onSetMediaItems for search results not yet indexed in local database.
    • Intercepts COMMAND_PLAY_PAUSE and COMMAND_STOP in onPlayerCommandRequest and bridges them directly to mediaPlayerHandler.onPlayerEvent.
    • Implements onMediaButtonEvent to handle hardware and assistant key events (KEYCODE_MEDIA_PAUSE, KEYCODE_MEDIA_PLAY, KEYCODE_MEDIA_PLAY_PAUSE, KEYCODE_MEDIA_STOP, KEYCODE_MEDIA_NEXT, KEYCODE_MEDIA_PREVIOUS).
    • Added fallback queue resumption from Liked songs in onPlaybackResumption when no saved queue exists.
  • NowPlayingCarScreen:
    • Added dynamic favorite (heart/like) toggle button in the Android Auto now-playing header alongside the queue action.
  • SimpMusicCarAppService:
    • Set createHostValidator() to HostValidator.ALLOW_ALL_HOSTS_VALIDATOR to allow execution on real head units and Desktop Head Unit (DHU) without signature restrictions.
  • SimpleMediaService:
    • Configured mediaSession?.setCustomLayout(commandButtonList) to export custom actions to automotive controllers.

Testing

Tested on:

  • Physical Android smartphone connected to Android Auto head unit in a vehicle.
  • Desktop Head Unit (DHU) emulator via ADB forwarding.

Verified scenarios:

  • Voice search: "Play [Artist/Song] on SimpMusic" correctly triggers YouTube Music query and starts playback with radio queue.
  • Voice transport controls: "Pause", "Play", "Next", "Previous" correctly toggle playback state.
  • Car screen UI: Like button in NowPlaying header toggles favorite state and updates database.
  • Cold boot resumption: launches liked songs fallback when saved playlist state is empty.

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.

1 participant