Help about Bluetooth AVRCP command extension

Unfortunately, I haven't found anything and I can't even create one, but I'd like to find an extension that handles the Bluetooth AVRCP commands received from the car stereo so I can start and stop my app's media player directly from the car stereo controls. Can anyone help me?

1 Like

What you can use already

Why AVRCP is a special case

  • AVRCP (Audio/Video Remote Control Profile) is part of Bluetooth Classic profiles (not BLE) and is used for media controls (play/pause/next).
  • Handling AVRCP means your app has to listen for the Bluetooth media control commands sent by the head-unit (car stereo) and map them into actions in your app.
  • AI2 and typical Bluetooth extensions are more oriented to device connection/data exchange, not automatically hooking into OS‐level media control events from the car head unit.
  • Also Android’s handling of media sessions, remote controls, Bluetooth metadata, etc., is more complex, and may require native code or special permissions
    What approach would work for you

Since there’s no plug‐and‐play extension I found, you have two main paths:

  1. Create or adapt an extension yourself
  • Write an AI2 extension (.aix) in Java that listens for Bluetooth AVRCP commands and raises events for your AI2 app (e.g., “OnPlayPressed”, “OnPausePressed”).
  • You’ll need to use Android’s Bluetooth API for AVRCP (e.g., BluetoothA2dp, MediaSession, MediaBrowser, BluetoothDevice.ACTION_MEDIA_BUTTON, etc.).
  • Then expose blocks in AI2 so you can link those events to your media player in your app.
  • This requires Java/Android development skills (or you hire someone/participate in community extension creation).
  • You’ll also need to consider Android permissions, handling of media button intents, Bluetooth profile connection, etc.
  1. Workaround inside AI2 (limited but possible)
  • Instead of directly catching AVRCP commands, you might intercept media button events in Android (if your app becomes a media player and registers a MediaSession and receives media button intents).
  • In your AI2 app, you can use the “ActivityStarter” or an extension to register for media button intents, then map those to your app’s Play/Pause control.
  • This isn’t purely AVRCP at the Bluetooth layer, but often when a head‐unit sends Play/Pause, Android generates a media‐button event.
  • So you might build this in AI2 with an extension or (if there is one) via an existing extension that handles media‐button events.

My recommendation for your next steps

  • Check in the AI2 community forums (e.g., “Media button”, “AVRCP”, “Car stereo controls”) to see if anyone has shared an extension for media button/AVRCP.
  • If you are comfortable or willing to learn, plan to create your own extension:
    • Research how to detect media button events in Android (e.g., via AudioManager, MediaSessionCompat, BroadcastReceiver for Intent.ACTION_MEDIA_BUTTON).
    • Expose those as events in an AI2 extension.
  • Alternatively, see if you can re-purposing a “media button listener” extension (if one exists) rather than a full Bluetooth AVRCP extension.

Hi Sriram,
Sorry for the delay in replying.
Thank you so much for your help and advice. I'll try to figure out how to intercept and manage the play and pause button events. Obviously, if I could find a ready-made extension, it would be easier, especially considering my limited time for testing, as I have a family with a small child.
In any case, thank you again. If I discover anything more, I'll share it here. In any case, I invite anyone who reads this post to help out further.
Have a good day.
Marco

1 Like

Have a nice day to and may you and your famaily be happy

1 Like