Re: [mediacapture-output] Setting the audio output for a whole context or page (#87)

> We probably need to add something to WebAudio as well.

Web audio seems easy enough to work around. Instead of:
```js
audioNode.connect(audioContext.destination);
```
you'd do
```js
const dest = audioContext.createMediaStreamDestination();
element.srcObject = dest.stream;
audioNode.connect(dest);
```
Not sure about audio worklet though.

> In most cases, it seems that pages will want to output all their audio to a single device.

The workaround is to collect all elements and set them:
```js
async function setAllElements(sinkId) {
  const elements = [...doc.getElementsByTagName("audio"),
                    ...doc.getElementsByTagName("video")];
  await Promise.all(elements.map(element => element.setSinkId(sinkId)));
}
```

-- 
GitHub Notification of comment by jan-ivar
Please view or discuss this issue at https://github.com/w3c/mediacapture-output/issues/87#issuecomment-631521457 using your GitHub account

Received on Wednesday, 20 May 2020 14:47:41 UTC