Android Question Bluetooth audio mic

yo3ggx

Active Member
Licensed User
Longtime User
Hello,
I want top use a Bluetooth headset with AudioStreamer.
I'm doing the initialization using
B4X:
HeadsetStreamer.Initialize2(VOICE_COMMUNICATION,"HeadsetStreamer",8000,True,16,STREAM_MUSIC)
Unfortunately audio is playing on the headset, but phone mic is still used for audio input.
Tried with DEFAULT or MIC as audioSource with the same results.

Any hint on how can I use the mic from the headset?

Thank you.
 

yo3ggx

Active Member
Licensed User
Longtime User
Are you able to capture audio from the headset with one of the other values: https://developer.android.com/reference/android/media/MediaRecorder.AudioSource ?
If so then you can use two AudioStreamer objects.
No, the mic from the BT headset is not used with any possible values accepted for the rec device in AudioStreamer, even if I activate SCO. More, if an USB audio device is connected to the smartphone, that one is used by default.
In between I had some partial success by changing the audio device after AudioStreamer is initialized (for both in and out), using setPreferredDevice for audioRecord and audioTrack inside AudioStreamer.
Audio routing in Android
If it will work as expected, I will post the code in the "Tutorials & Examples" section of the forum, maybe can be helpful for other users too. You can select not only BT headset, but even USB audio devices, internal earpiece or speaker, wired headset and so on.
 
Upvote 0
Top