I make a player that should play only through headphones (wired or Bluetooth), but not through the speaker.
If you turn off the headphones during playback, the player automatically pauses.
When (Bluetooth) headphones are connected back and I get the ACTION_AUDIO_STATE_CHANGED
event, I resume playback. But for a few seconds, the sound goes through the builtin speaker and only then goes to the headphones. I think to fix this by setting the device to output. I can get the device id from AudioManager. But how to pass it to OpenSL ES?
Or maybe there is a way to completely prevent playback through the builtin speaker?
Or another way to solve this problem?
P.S. Santa, where is you when you are so needed? Help me, please!