flecs
flecs copied to clipboard
[Feature Request] Select audio output device
It would be nice if I could set a custom audio output device
Its usually the operating system's job to do that, for example:
Windows 10 lets you define input/output devices for each application separately via
“App Volume And Device Preferences”
can be opened with command ms-settings:apps-volume
(You can set that as shortcut target)
See some random tutorial
And random screenshot of that feature:
Actually it's not so usual... Microsoft added this functionality to Windows Media Player with Windows 7 release and Windows 8.1 audio settings still can't do that.
There's an extension for Chrome called AudioXout addressing this issue: it doesn't remember device choice (it should, but doesn't work) and requires only microphone permissions; maybe it could be ported as a plugin for this app.
If anyone want to make a plugin for this, should probably use HTMLMediaElement.setSinkId()
could use inspiration from https://github.com/rain-fighters/AudioPick
I needed this feature, and implement the simplest dumb plugin with hardcoded deviceId. For anyone that need this, just create a new directory named "pref-audio-out-device" at "plugins" inside create a file named "front.js" with this content:
module.exports = () => {
document.addEventListener('apiLoaded', apiEvent => {
changeToPrefAudioOutDevice();
navigator.mediaDevices.ondevicechange = (e) => {
changeToPrefAudioOutDevice();
};
}, { once: true, passive: true })
};
function changeToPrefAudioOutDevice() {
const prefAudioOutDeviceId = '74b147ea818349756def2d6dae3a5422f8be7f0ef7b91749f61cfbe7a83730fe'; //TODO load from plugin options
navigator.mediaDevices.enumerateDevices().then((devices) => {
devices.forEach((device) => {
console.log(`${device.kind}: ${device.label} id = ${device.deviceId}`);
if (device.kind === 'audiooutput' && // device type is audio output
device.deviceId === prefAudioOutDeviceId && // preferred audio out device is connected
document.querySelector('.video-stream,.html5-main-video').SinkId !== prefAudioOutDeviceId) { // preferred audio out device is not already set
document.querySelector('.video-stream,.html5-main-video').setSinkId(device.deviceId); // set preferred audio out device
}
});
}).catch((err) => {
console.error(`${err.name}: ${err.message}`);
});
}
'74b147ea818349756def2d6dae3a5422f8be7f0ef7b91749f61cfbe7a83730fe' is the hardcoded deviceId of My preferred audio out device :) See the console log for a list of your devices.
The navigator.mediaDevices.ondevicechange is not working, only change at app start :(
Testing with git version, with kde plasma 5.24.6
Just want to express my interest in this as well. I tried what Azureit explained but had compilation failures which I don't know how to diagnose/fix. Hoping this will be implemented at some point, since setting it in Windows' sound mixer doesn't persist after rebooting (edit: even restarting the application).
Just want to express my interest in this as well. I tried what Azureit explained but had compilation failures which I don't know how to diagnose/fix. Hoping this will be implemented at some point, since setting it in Windows' sound mixer doesn't persist after rebooting.
Try going to Window Settings > Audio (maybe under Devices) > App Volume and selecting audio device. The names might be different (I'm not on Windows now so I can't check), but I know that there's an option in Settings that persists even after reboot. I've used it before in both Win 10 and 11.
But +1 for adding this feature to the YTM app.
i also tried azureit mentioned and no success hopefully this does get added
should be pretty easy to do after those:
- https://developer.chrome.com/blog/audiocontext-setsinkid/ (Published on Wednesday, January 11, 2023)
- https://github.com/th-ch/youtube-music/pull/951 (Merged on Sunday, January 8, 2023)
Anyone want to give it a shot?