Skip to main content
setAudioDevice(deviceId) Switches the local audio stream to the device identified by deviceId. The deviceId should match a deviceId value returned by enumerateDevices(). If the requested device becomes unavailable (for example, a Bluetooth device that disconnects), the resolved deviceId may differ from the one requested.

Parameters

deviceId
string
required
The deviceId of the audio device to switch to.

Return value

Returns a Promise<{ deviceId: string }> with the deviceId of the audio device that was actually applied.

Example

const { devices } = await call.enumerateDevices();
const speakerphone = devices.find(
  (d) => d.kind === 'audioinput' && d.label.includes('Speakerphone')
);
if (speakerphone) {
  const { deviceId } = await call.setAudioDevice(speakerphone.deviceId);
  console.log('Now using audio device:', deviceId);
}

See also