Open mesutyigit opened 2 years ago
I join. Howler is a cool audio library. I use it for mobile sound. I would like to use it for the desktop, but due to the fact that there is no support for setSinkId, I have to use something else
@Nawarius , what did you end up using?
@adamthewan, Nothing. The task of changing audio outputs fell off and I stopped these experiments
I've finally found a solution for using Howler.js with the setSinkId
method. This approach works exclusively with the html5
. Hence, it must be explicitly enabled in the Howl instance:
const sound = new Howl({
src: [soundPath],
html5: true, // Ensure html5 mode is enabled for setSinkId to work
onplay: () => {
const audioElement = sound._sounds[0]._node; // Access the underlying HTMLAudioElement
if (typeof audioElement.setSinkId === 'function') {
audioElement
.setSinkId('sink_device_id')
.then(() => {
console.log('Audio output successfully redirected.');
})
.catch((error) => {
console.error('Failed to redirect audio output:', error);
});
}
},
});
https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/setSinkId
your API doesn't provide "setSinkId".
It would be great if you can change the speaker device programmatically.
navigator.mediaDevices.enumerateDevices() result may include multiple "audiooutput" device.