mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
Add Video Player Mousewheel Volume Control
(if hide-video-player plugin is disabled)
This commit is contained in:
@ -1,3 +1,5 @@
|
|||||||
|
const { isEnabled } = require("../../config/plugins");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This is used to determine if plugin is actually active
|
This is used to determine if plugin is actually active
|
||||||
(not if its only enabled in options)
|
(not if its only enabled in options)
|
||||||
@ -12,6 +14,7 @@ module.exports = (win) => {
|
|||||||
// Thats the reason the timing is controlled from main
|
// Thats the reason the timing is controlled from main
|
||||||
win.webContents.once("did-finish-load", () => {
|
win.webContents.once("did-finish-load", () => {
|
||||||
win.webContents.send("restoreAddEventListener");
|
win.webContents.send("restoreAddEventListener");
|
||||||
|
win.webContents.send("setupVideoPlayerVolumeMousewheel", !isEnabled("hide-video-player"));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,21 @@ module.exports = (options) => {
|
|||||||
setupSliderObserver(options);
|
setupSliderObserver(options);
|
||||||
setupArrowShortcuts(options);
|
setupArrowShortcuts(options);
|
||||||
firstRun(options);
|
firstRun(options);
|
||||||
|
ipcRenderer.once("setupVideoPlayerVolumeMousewheel", (_event, toEnable) => {
|
||||||
|
if (toEnable)
|
||||||
|
setupVideoPlayerOnwheel(options);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function setupVideoPlayerOnwheel(options){
|
||||||
|
// Add onwheel event to video player
|
||||||
|
$("#main-panel").onwheel = event => {
|
||||||
|
event.preventDefault();
|
||||||
|
// Event.deltaY < 0 means wheel-up
|
||||||
|
changeVolume(event.deltaY < 0, options);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function toPercent(volume) {
|
function toPercent(volume) {
|
||||||
return Math.round(Number.parseFloat(volume) * 100);
|
return Math.round(Number.parseFloat(volume) * 100);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user