This commit is contained in:
Araxeus
2021-05-17 00:07:28 +03:00
parent 9c7a70e056
commit e5473cdfe4

View File

@ -46,20 +46,20 @@ function injectVolumeHud(noVid) {
let hudFadeTimeout; let hudFadeTimeout;
function showVolumeHud(volume) { function showVolumeHud(volume) {
let volumeHud = $("#volumeHud"); let volumeHud = $("#volumeHud");
if (!volumeHud) return; if (!volumeHud) return;
volumeHud.textContent = volume + '%'; volumeHud.textContent = volume + '%';
volumeHud.style.opacity = 1; volumeHud.style.opacity = 1;
if (hudFadeTimeout) { if (hudFadeTimeout) {
clearTimeout(hudFadeTimeout); clearTimeout(hudFadeTimeout);
} }
hudFadeTimeout = setTimeout(() => { hudFadeTimeout = setTimeout(() => {
volumeHud.style.opacity = 0; volumeHud.style.opacity = 0;
hudFadeTimeout = null; hudFadeTimeout = null;
}, 2000); }, 2000);
} }
/** Add onwheel event to video player */ /** Add onwheel event to video player */
@ -83,12 +83,12 @@ function saveVolume(volume, options) {
//without this function it would rewrite config 20 time when volume change by 20 //without this function it would rewrite config 20 time when volume change by 20
let writeTimeout; let writeTimeout;
function writeOptions(options) { function writeOptions(options) {
if (writeTimeout) clearTimeout(writeTimeout); if (writeTimeout) clearTimeout(writeTimeout);
writeTimeout = setTimeout(() => { writeTimeout = setTimeout(() => {
setOptions("precise-volume", options); setOptions("precise-volume", options);
writeTimeout = null; writeTimeout = null;
}, 1500) }, 1500)
} }
/** Restore saved volume and setup tooltip */ /** Restore saved volume and setup tooltip */
@ -133,9 +133,9 @@ function changeVolume(toIncrease, options) {
const videoStream = $(".video-stream"); const videoStream = $(".video-stream");
// Apply volume change if valid // Apply volume change if valid
const steps = (options.steps || 1) / 100; const steps = (options.steps || 1) / 100;
videoStream.volume = toIncrease ? videoStream.volume = (toIncrease ?
Math.min(videoStream.volume + steps, 1) : Math.min(videoStream.volume + steps, 1) :
Math.max(videoStream.volume - steps, 0).toFixed(2); Math.max(videoStream.volume - steps, 0)).toFixed(2);
// Save the new volume // Save the new volume
saveVolume(toPercent(videoStream.volume), options); saveVolume(toPercent(videoStream.volume), options);
@ -152,7 +152,7 @@ function changeVolume(toIncrease, options) {
} }
function setupVolumeOverride(options) { function setupVolumeOverride(options) {
const video = $('video'); const video = $('video');
video.addEventListener("canplay", () => { video.addEventListener("canplay", () => {
if (typeof options.savedVolume === "number") { if (typeof options.savedVolume === "number") {