Table of Contents
setAudioDestination()
wrtc.setAudioDestination() changes which local audio destination (speaker) to use. It affects all current and future calls.
By default the audio destination is picked by the browser. While most of the times browsers do succeed in picking the right audio destination sometimes they select another one than the user prefers. On devices with multiple audio destinations you can select which one to use by calling wrtc.setAudioDestination() with the desired destination's unique ID as argument.
On Chrome you can get a list of available audio destinations using wrtc.get("audioDestinations").
The difference between wrtc.setAudioDestination() and call.adv.setAudioDestination() is that while wrtc.setAudioDestination() affects all current and future calls call.adv.setAudioDestination() affects only one particular call.
Arguments
wrtc.setAudioDestination(destinationID)
- destinationID - (optional) string containing the unique destination ID of the audio output device (speaker) you want to use for all current and future calls, or special values:
- "default" - system's default audio output device
- "communications" - system's default audio output device for communications
wrtc.audioDestination will be set to supplied destinationID to ensure future calls also deliver audio to selected device.
If no destinationID is supplied default audio output device will be used.
Returns
Nothing.
Tips & Tricks
Sometimes when you use headphones you want call audio to go to the headphones - but still want the ring signal to use main speakers. You can then use wrtc.setAudioDestination() to send call audio to headphones but use setSinkId() to redirect audio object containing ring signal to main speaker:
document.getElementById('ringer').setSinkId(destID);
Please note that this might not work on all devices, some devices cut off main speakers by hardware when headphones are inserted.