Status Update
Comments
ba...@google.com <ba...@google.com> #2
Because Media2 is using the Media1 media session. A media button event coming from bluetooth is converted into an onPlay/onPause
command by the Media1 MediaSessionCompat
support library. I'm pretty sure that BT commands arrive via media1 at least for the three BT headsets that I'm usually testing with.
We can not support you 1:1 with your app I'm afraid. So you would have to narrow down to some more specific questions.
I would wonder whether you can repro this on that phone with your BT headphones with the
il...@google.com <il...@google.com>
ib...@google.com <ib...@google.com>
ni...@ryfacto.fr <ni...@ryfacto.fr> #3
ni...@ryfacto.fr <ni...@ryfacto.fr> #4
Do you have a sample code using MediaSessionCompat but not ExoPlayer to demonstrate how we are supposed to use the API without ExoPlayer please ?
Thanks a lot !
ni...@ryfacto.fr <ni...@ryfacto.fr> #5
Is there an issue opened for this problem ?
ba...@google.com <ba...@google.com> #6
Can you tell us in a bit more detail how you fixed the problem?
The SOF post says that the media button is not properly routed to the app as expected. Did your fix change something in the priority? When you check with
adb shell dumpsys media_session
do you see a change in the section Audio playback (lastly played comes first)
with your fix?
I don't know what is the difference between TTS player and traditional players that would cause this, but your feedback would be appreciated in the sense that we would learn what you actually did to receive the media button events.
ni...@ryfacto.fr <ni...@ryfacto.fr> #7
Sorry I lost a lot of time on this issue, I can't invest more for the moment.
I just played a silent sound for less than 1s using MediaPlayer
class and when done I start using TextToSpeech
.
You have my sample project demonstrating the issue, just add the play of silence, on completion start speaking using TextToSpeech
and it will work.
I hope this can help you fix the issue. 😉
to...@google.com <to...@google.com>
to...@google.com <to...@google.com> #8
Based on the analysis above, it sounds as the TextToSpeech
playback is not set up in a way that media buttons can be routed correctly to the app.
Assigning to the TTS team for further triage. Is this a known issue? The linked SO post in #5 suggests this problem exists since Android Oreo.
(Apologies if you are not the team maintaining the TextToSpeech
implementation, please reassign as needed)
rn...@google.com <rn...@google.com>
is...@google.com <is...@google.com>
ib...@google.com <ib...@google.com>
rn...@google.com <rn...@google.com> #9
TTS playback doesn't inherently handle the media buttons - quite simply because it cannot be paused or rewound like a traditional media source.
If you do want such functionality, please use the .synthesizeToFile() method (instead of .speak()). This will give you a wav file which you can then put through a media player, which will then handle the media playback buttons.
Description
Version used: 1.2.1
Devices/Android versions reproduced on: Google Pixel 5a / Android 12
I encounter a problem handling media button events when they come from Bluetooth headsets. It works fine using wired ones.
I followed the official guide about building an Audio app :
I also tried to understand how it works using the sample project UAMP :
But I cannot figure out what I am missing to make it work with Bluetooth headsets.
I created a sample project demonstrating the issue here :
Could you please help me figure out what I am missing ?
Thank you very much !
Nicolas