- From: Christoph Guttandin via GitHub <sysbot+gh@w3.org>
- Date: Thu, 12 Oct 2023 15:13:36 +0000
- To: public-webrtc-logs@w3.org
There are a few other APIs which follow a slightly different pattern than `enumerateDevices()`. `matchMedia()` for example returns a `MediaQueryList` which does implement an `EventTarget` and fires events whenever it changes. `requestMIDIAccess()` returns a Promise which resolves with a `MIDIAccess` object. It has properties to synchronously access the `inputs` and `outputs`. But it implements an `EventTarget`, too. It fires a `statechange` event whenever the list of available devices changes. By the time the event is fired the `inputs` and `outputs` are already updated. When applying the same concept to `enumerateDevices()` it could look a bit like this. ```js navigator.mediaDevices .enumerateDevices() .then((deviceList) => { // Log the latest list of devices. console.log(deviceList.devices); deviceList.onchange = () => { // Log the list of devices again. // The list got updated already just before the event fired. console.log(deviceList.devices); }; }); ``` The Permissions API is another API which follows this pattern. I know that this would be a breaking change. But maybe there is a way to introduce something like this in a backwards compatible way. -- GitHub Notification of comment by chrisguttandin Please view or discuss this issue at https://github.com/w3c/mediacapture-main/issues/972#issuecomment-1759806894 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 12 October 2023 15:13:38 UTC