0

I'm building an app which needs to trigger an audio menu. For that purpose I need to intercept clicks on media buttons, specifically the play/pause button.

It is working fine using wired headsets and using the media button present in the Notification for my foreground service.

But I do not receive media button events when I use a Bluetooth Headset.

I am missing something because the UAMP and media3 samples work.

Question is : what am I missing ?

The samples are so complex I could not find out, I wish there was a sample code not using ExoPlayer but there is not.

I made a sample project demonstrating the issue here : https://github.com/Ryfacto/MediaBluetoothHeadsetIssue.

Thank you for your help, I'm really desperate.

nverinaud
  • 1,270
  • 14
  • 25

2 Answers2

0

The problem seems related to an android bug when using TTS to play audio.

See this answer : Catching android media button events

This issue is known by Google and referenced here : https://issuetracker.google.com/issues/249741615

nverinaud
  • 1,270
  • 14
  • 25
0

If you use media3 it supports your requirements

reference

https://youtu.be/sTIBDcyCmCg?t=737

you just need to extend MediaSessionService/medialibraryservice and override onGetSession

Details of MediaSessionService/medialibraryservice

1234567
  • 2,226
  • 4
  • 24
  • 69
  • Thanks for your answer ! I just updated mine with the reference to the issue in Google Issue Tracker. It is a known issue... – nverinaud Oct 25 '22 at 15:22