Closed KarimAbdo closed 5 years ago
Thanks @KarimAbdo
Do you find that there is a need for an AudioManager
utility that handles common events such as bluetooth connection, headset connect/disconnect or proximity sensor detection? If so, we can discuss in our next planning meeting.
I think it will be very helpful.
Also i would think maybe an integrated speed test would be very helpful, if you could integrate it within the call. so for example if the internet got weak you can either send lower quality instead of the slow motion one that is already there, or if it is too weak maybe freeze the video with a message, or an event.
It would be great it if it just did the sensible thing by default (prioritize headsets over the speaker). What is is set to do by default now? We are tracking down some audio problems in our app and this might be the cause.
Thanks for the feedback everyone. We added a few tasks to our backlog to accommodate this feature. I will update the ticket when we start the work.
Thanks!
Any update on this? We are running into some volume issues on wireless headphones. (and when there are no headphones)
No update @mcorner
The resources for this feature have not been allocated. Can you elaborate on the volume issues you are experiencing? Seems worthy of a separate issue.
Unfortunately, my info is pretty sketchy as it came from users. Basically sometimes the audio is super low through the speakers and they can't hear anything, then they switched to wireless headset and it still was quiet, then they switched to wired and it was fine.
We are using this: setAudioFocus(true); when stating a call, and: setAudioFocus(false); on onDisconnected
private void setAudioFocus(boolean focus) {
if (focus) {
previousAudioMode = audioManager.getMode();
// Request audio focus before making any device switch.
audioManager.requestAudioFocus(null, AudioManager.STREAM_VOICE_CALL,
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
/*
* Use MODE_IN_COMMUNICATION as the default audio mode. It is required
* to be in this mode when playout and/or recording starts for the best
* possible VoIP performance. Some devices have difficulties with
* speaker mode if this is not set.
*/
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
/*
* Always disable microphone mute during a WebRTC call.
*/
previousMicrophoneMute = audioManager.isMicrophoneMute();
audioManager.setMicrophoneMute(false);
} else {
audioManager.setMode(previousAudioMode);
audioManager.abandonAudioFocus(null);
audioManager.setMicrophoneMute(previousMicrophoneMute);
}
}
Hey @mcorner
Do you have device info from these customers? Also I highly recommend our Troubleshooting Audio Guide for optimal audio quality.
I am able to reproduce this on my own Nexus 5x. The call connects fine (the other end is an iOS device). The audio coming out of the nexus is way too low in volume, even if I turn it up to max. It is exactly like the difference between having a phone call volume vs speaker call volume (if I put the phone to my head it is the right volume). If I put in wired headphones it works just fine on Android. I am using the code copied right out of the quickstart for the audioManager.
Thanks @mcorner
I'll have a look.
I will try experimenting with: setSpeakerphoneOn(true); to see if that will just always route it to the speakerphone at the right volume.
However, looking at other code, it seems this problem might not be as simple as trusting Android to do the "right thing"..... For instance:
It basically routes audio between the speaker, headset, and Bluetooth based on what is plugged in and when.
Ok, I did some experimentation. Setting the speakerPhone to true fixes the issue. Of course that means that when you plug in a wired headset it still comes out of the speakerphone. Wireless (bluetooth) headsets don't seem to work at all. We could write a bunch of code (like what appears in AppRTCAudioManager above), but that starts to seem like we are doing too much work to get something simple to work. Any hope that Twilio can solve this for us?
Hey @mcorner
What you are suggesting is basically the scope of this issue. We would like to ship something either with the SDK or separately that properly routes audio for developers as opposed to having all our customer's implement this themselves. We have this story in our backlog, but have not allocated a resource to implement it yet.
Apologies for the delay on getting to this feature.
Thanks!
@aaalaniz Any update on Android bluetooth support?
We saw this error in our logs:
java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10107 nor current process has android.permission.BLUETOOTH.
Do we just need to add the <uses-permission android:name="android.permission.BLUETOOTH" />
to our manifest?
Hey @seanadkinson
No resources have been allocated to this story and yes for this error you just need BLUETOOTH permission.
Thanks!
Hello! I would like to ask if, apart from this logic that you have created, it is possible for me to be able to simulate the connection of a headset ... for example: to make the "think" device that has a headset connected. sorry for my english from google translator :D
Hey @PequenoAprendiz,
From doing some research it seems like there isn't an official Android way to do this, but I did find a helper library that allows you to create some mock Bluetooth devices. Hope this helps!
Hey @KarimAbdo,
Thanks for bringing this to our attention. At this time we don't have this on our roadmap. Perhaps in the future we may consider this as an external project.
Regards,
Zack
This only worked on the nexus devices. One HTC, Sony and samsung it kept using the loudspeaker.
i solved it by adding a BroadcastReceiver that detects if the headphones get connected/disconnected