mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 02:31:45 +00:00
Merge branch 'master' into fix-restart-on-config-change
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
const { ipcRenderer } = require("electron");
|
||||
const { globalShortcut } = require('@electron/remote');
|
||||
|
||||
const { setOptions, setMenuOptions } = require("../../config/plugins");
|
||||
const { setOptions, setMenuOptions, isEnabled } = require("../../config/plugins");
|
||||
|
||||
function $(selector) { return document.querySelector(selector); }
|
||||
let api;
|
||||
@ -13,6 +13,8 @@ module.exports = (options) => {
|
||||
}, { once: true, passive: true })
|
||||
};
|
||||
|
||||
module.exports.moveVolumeHud = moveVolumeHud;
|
||||
|
||||
/** Restore saved volume and setup tooltip */
|
||||
function firstRun(options) {
|
||||
if (typeof options.savedVolume === "number") {
|
||||
@ -34,6 +36,11 @@ function firstRun(options) {
|
||||
injectVolumeHud(noVid);
|
||||
if (!noVid) {
|
||||
setupVideoPlayerOnwheel(options);
|
||||
if (!isEnabled('video-toggle')) {
|
||||
//video-toggle handles hud positioning on its own
|
||||
const videoMode = () => api.getPlayerResponse().videoDetails?.musicVideoType !== 'MUSIC_VIDEO_TYPE_ATV';
|
||||
$("video").addEventListener("srcChanged", () => moveVolumeHud(videoMode()));
|
||||
}
|
||||
}
|
||||
|
||||
// Change options from renderer to keep sync
|
||||
@ -61,6 +68,16 @@ function injectVolumeHud(noVid) {
|
||||
}
|
||||
}
|
||||
|
||||
let hudMoveTimeout;
|
||||
function moveVolumeHud(showVideo) {
|
||||
clearTimeout(hudMoveTimeout);
|
||||
const volumeHud = $('#volumeHud');
|
||||
if (!volumeHud) return;
|
||||
hudMoveTimeout = setTimeout(() => {
|
||||
volumeHud.style.top = showVideo ? `${($('ytmusic-player').clientHeight - $('video').clientHeight) / 2}px` : 0;
|
||||
}, 250)
|
||||
}
|
||||
|
||||
let hudFadeTimeout;
|
||||
|
||||
function showVolumeHud(volume) {
|
||||
|
||||
Reference in New Issue
Block a user