> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# setMediaElementSinkId

> setMediaElementSinkId function in the WebRTC namespace.

### 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](/docs/browser-sdk/v3/js/reference/webrtc/supports-media-output).

#### Parameters

**`el`** `HTMLMediaElement | null` — required

Target element.

---

**`deviceId`** `string` — required

Id of the audio output device.

---

#### Returns

`Promise<undefined>`

#### Example

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