standardized-audio-context icon indicating copy to clipboard operation
standardized-audio-context copied to clipboard

How to choose the output device?

Open aaronvg opened this issue 2 years ago • 2 comments

Chromium seems to have added support to choose the output device (see https://github.com/WebAudio/web-audio-api/pull/2498)

Are there any plans to add setSinkId to this library?

Could I just cast the AudioContext object from this library into the native one and call that method? Or maybe the other way around -- cast a native AudioContext to the standardized one? Or what's the best way of accessing the native AudioContext?

aaronvg avatar Jan 24 '23 05:01 aaronvg

Hi @aaronvg,

thanks for creating this issue. My current thinking is that it could probably be implemented in a standards compliant way with very minimal effort.

audioContext.sinkId would always return '' since that is the default. And any call to audioContext.sinkId() would throw a NotSupportedError in those browsers that don't implement it.

The spec also includes a step to check the 'speaker-selection' permission but this seems to be in no browser so far.

Does that sound about right?

chrisguttandin avatar Jan 26 '23 09:01 chrisguttandin

I've got my eyes on this one, since I'd love to be able to "natively" choose the output device in higher level libraries like Tone.js without needing to go through extra steps like outlined in https://github.com/Tonejs/Tone.js/issues/877

I would expect audioContext.sinkId to return the currently assigned sinkId which could be '' if you haven't explicitly set it via audioContext.setSinkId(...) right?

baparham avatar Feb 08 '23 21:02 baparham