Closed neubami94 closed 1 year ago
We are currently dealing with the same issue.
I tried calling audioSwitch.availableAudioDevices after granting the permissions and it does not contain the bluetooth device. So thats why it does not emit.
I hotfixed the issue by writing a bluetooth permission manager, observing when a permission is granted and then calling this:
@Synchronized
fun restart(): Completable {
return Completable.fromCallable {
logThread("Restart")
audioSwitch.stop()
audioSwitch.start { audioDevices, selectedAudioDevice ->
selectedAudioDevice?.let { currentlyActiveOutput.onNext(selectedAudioDevice) }
availableAudioOutputs.onNext(audioDevices)
}
}
}
@zelenmi6 any update on this?? i am still facing the error with 1.1.5 audioswitch in the listener I'm getting the Bluetooth device name but the audio is still coming from the earpiece and later on the listener also gives Earpiece
@tronku we ditched this twilio lib and implemented a custom solution
There's no way for AudioSwitch to automatically know that the bluetooth permission is granted, so you'd need to manually restart it yourself.
@davidliu is correct. AudioSwitch expects the permissions it requires to be granted before it is started. If permissions are granted afterwards, then it should be restarted.
After granting the permission if we call the below code
_audioSwitch.start { listAudioDevice: List<AudioDevice?>?, selectedDevice: AudioDevice? ->}
got error message: Redundant start() invocation while already in the started or activated state
How to restart the audio switch? @afalls-twilio @davidliu
stop
then start
.
@davidliu Thank you so much it's working fine.
I have one more query regarding the audio switch. Might have you help me? Precondition: Bluetooth is connected When I select audio from Bluetooth to phone/speaker sometimes voice comes in speaker/phone and sometimes in Bluetooth.
For more info please check this one:https://github.com/twilio/audioswitch/issues/163
Describe the bug audioDevices do not update after granting bluetooth permission (Android 12)
To Reproduce Steps to reproduce the behavior:
AND
Expected behavior audioDevices emit and contain Bluetooth headset
Actual behavior audioDevices do not emit and do not contain Bluetooth headset
Application Logs
AudioSwitch Version
Android Device (please complete the following information):