Add MPRIS volume control

Fixes #776.
This commit is contained in:
Jonathan Müller
2022-07-11 19:55:16 +02:00
parent 2499f574ef
commit d9c51063f4
2 changed files with 28 additions and 1 deletions

View File

@ -23,6 +23,7 @@ module.exports = () => {
(is.linux() && config.plugins.isEnabled('shortcuts'))) {
setupTimeChangeListener();
setupRepeatChangeListener();
setupVolumeChangeListener();
}
const video = $('video');
// name = "dataloaded" and abit later "dataupdated"
@ -74,3 +75,13 @@ function setupRepeatChangeListener() {
// Emit the initial value as well; as it's persistent between launches.
ipcRenderer.send('repeatChanged', $('#right-controls .repeat').title);
}
function setupVolumeChangeListener() {
const volumeObserver = new MutationObserver(mutations => {
ipcRenderer.send('volumeChanged', mutations[0].target.value);
});
volumeObserver.observe($('#right-controls .volume-slider'), { attributeFilter: ["value"] });
// Emit the initial value as well; as it's persistent between launches.
ipcRenderer.send('volumeChanged', $('#right-controls .volume-slider').value);
}