setMediaElementSinkId

View as Markdown

setMediaElementSinkId

  • Const setMediaElementSinkId(el, deviceId): Promise<undefined>

Assigns the specified audio output device to the specified HTMLMediaElement. The device with id deviceId must be an audio output device. Asynchronously returns whether the operation succeeded.

Some browsers do not support output device selection. You can check by calling supportsMediaOutput.

Parameters

el
HTMLMediaElement | nullRequired

Target element.

deviceId
stringRequired

Id of the audio output device.

Returns

Promise<undefined>

Example

1const el = document.querySelector("video");
2const outDevices = await SignalWire.WebRTC.getSpeakerDevicesWithPermissions();
3await SignalWire.WebRTC.setMediaElementSinkId(el, outDevices[0].deviceId);
4// true