From c48260f10c80346c346b035858a61ac70e559e1b Mon Sep 17 00:00:00 2001 From: Araxeus Date: Sat, 17 Apr 2021 16:42:13 +0300 Subject: [PATCH] add advanced option to change volume steps --- config/defaults.js | 6 ++++++ plugins/precise-volume/front.js | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/config/defaults.js b/config/defaults.js index fb87e566..4b484951 100644 --- a/config/defaults.js +++ b/config/defaults.js @@ -45,6 +45,12 @@ const defaultConfig = { enabled: false, urgency: "normal", unpauseNotification: false + }, + "precise-volume": { + enabled: false, + steps: 1, //percentage of volume to change + arrowsShortcut: true, //enable ArrowUp + ArrowDown local shortcuts + savedVolume: undefined //plugin save volume between session here } }, }; diff --git a/plugins/precise-volume/front.js b/plugins/precise-volume/front.js index d6424df1..ed0cf4c5 100644 --- a/plugins/precise-volume/front.js +++ b/plugins/precise-volume/front.js @@ -86,11 +86,12 @@ function changeVolume(increase, options) { // Need to change both the slider and the actual volume const videoStream = document.querySelector(".video-stream"); const slider = document.querySelector("#volume-slider"); - + // Apply volume change if valid + const steps = options.steps / 100; videoStream.volume = increase ? - Math.min(videoStream.volume + 0.01, 1) : - Math.max(videoStream.volume - 0.01, 0); + Math.min(videoStream.volume + steps, 1) : + Math.max(videoStream.volume - steps, 0); // Save the new volume saveVolume(toPercent(videoStream.volume), options);