Navigator.mediaDevices has * an enumerateDevices function, which provides the same functionality as MediaStreamTrack.getSources and adds audio output devices to the list, and * a devicechange event to notify when the set of devices available have changed. enumerateDevices is enabled by default, and the devicechange event is behind a flag.
Docs: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices https://developer.mozilla.org/en-US/docs/Web/API/Navigator
Samples: https://webrtc.github.io/samples/src/content/devices/input-output/