-
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to configure session to use Bluetooth headset mic on Android? #106
Comments
Hi. |
In order to receive audio from Bluetooth microphone in Android, you have to implement the audio capture at native side while managing the Bluetooth remote device connect and disconnection by listening through ACTION_CONNECTION_STATE_CHANGED events while also managing the mobile Bluetooth disconnection through ACTION_STATE_CHANGED events. In order to capture audio, you should implement AudioRecord class. Before calling the startRecording method of AudioRecord, call startBluetoothSco then setBluetoothScoOn(true) of AudioManager. When Bluetooth remote device is reconnected after a disconnection, you have to wait for STATE_CONNECTED event then stop the audio recording(AudioRecord class) and add a delay of 5secs(thread sleep) so that device is connected and ready before starting the recording again. When done remember to clean up the event listeners and calling stopBluetoothSco() setBluetoothScoOn(false) of AudioManager. Hope this helps :) |
That sounds like something that a good audio recorder plugin should manage. The record plugin has a feature request for it: llfbandit/record#84 . There was also a PR llfbandit/record#225 which was later closed by its author 🤷 |
@ryanheise Agreed, it's out of scope for audio_session. I am facing an issue; I think you can suggest something on it. I was looking for a way I can listen to some event that would inform me that audioFocus is now available and not being used by other app so I can safely request for audioFocus. Reason being gaining audioFocus if other app is using it, will cause the music player to stop abruptly. |
@bilalahmed24 I don't think the API supports this by design. If Android wants to tell you when the audio focus is available again, it will give you type |
@ryanheise I believe this configuration, will provide the ability for app to regain audio focus: setAcceptsDelayedFocusGain |
I've been struggling to get audio input via Bluetooth headset working on Android:
The text was updated successfully, but these errors were encountered: