====== 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 [[ixnx:wrtc:js:api:sources_array|desired destination's unique ID]] as argument. On Chrome you can get a list of available audio destinations using [[ixnx:wrtc:js:api:wrtc:get|wrtc.get("audioDestinations")]]. The difference between wrtc.setAudioDestination() and [[ixnx:wrtc:js:api:call:adv.setaudiodestination|call.adv.setAudioDestination()]] is that while wrtc.setAudioDestination() affects //all// current and future calls [[ixnx:wrtc:js:api:call:adv.setaudiodestination|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 [[ixnx:wrtc:js:api:wrtc:audiodestination|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 [[https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/setSinkId|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. ===== See also ===== [[ixnx:wrtc:js:api:wrtc:audiodestination|wrtc.audioDestination]] [[ixnx:wrtc:js:api:call:adv.setaudiodestination|call.adv.setAudioDestination()]] [[ixnx:wrtc:js:api:wrtc:get|wrtc.get("audioDestinations")]] [[ixnx:wrtc:js:api:sources_array|audio destinations]]