mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +00:00
Merge branch 'master' of github.com:th-ch/youtube-music into native-pip
* 'master' of github.com:th-ch/youtube-music: fix PiP hotkey active in searchbox remove titlebar from in-app-menu+PiP Bump "@cliqz/adblocker-electron" version Only run the release stage if it is the main repo Only build without release if it is a fork Use del-cli instead of del (for windows) Replace electron-icon-maker by a more up-to-date fork Adapt CI to yarn v3 Migrate to yarn v3 Track transitioning status Fixed recursive volume changes that caused cpu spike, Switched Repeat Modes to NONE|ONE|ALL Remove references to rimraf Add first version for crossfade plugin removed unnecessary if and used better Repeat change detection connected mpris shuffle, fixed volume, mpris volumes allowed 0.0-1.0 fixed 'repeatChanged' modes being different depending on selected youtube music language fix precise-volume+searchbox interaction fix navbar position
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
const { ipcRenderer } = require("electron");
|
||||
|
||||
const { toKeyEvent } = require("keyboardevent-from-electron-accelerator");
|
||||
const keyEventAreEqual = require("keyboardevents-areequal");
|
||||
|
||||
const { getSongMenu } = require("../../providers/dom-elements");
|
||||
const { ElementFromFile, templatePath } = require("../utils");
|
||||
|
||||
@ -71,9 +74,12 @@ const listenForToggle = () => {
|
||||
const player = $('#player');
|
||||
const onPlayerDblClick = player.onDoubleClick_;
|
||||
|
||||
ipcRenderer.on('pip-toggle', (_, isPip) => {
|
||||
const titlebar = $(".cet-titlebar");
|
||||
|
||||
ipcRenderer.on("pip-toggle", (_, isPip) => {
|
||||
if (isPip) {
|
||||
replaceButton(".exit-fullscreen-button", originalExitButton).onclick = () => togglePictureInPicture();
|
||||
replaceButton(".exit-fullscreen-button", originalExitButton).onclick =
|
||||
() => togglePictureInPicture();
|
||||
player.onDoubleClick_ = () => {};
|
||||
expandMenu.onmouseleave = () => middleControls.click();
|
||||
if (!playerPage.playerPageOpen_) {
|
||||
@ -81,12 +87,14 @@ const listenForToggle = () => {
|
||||
}
|
||||
fullScreenButton.click();
|
||||
appLayout.classList.add("pip");
|
||||
if (titlebar) titlebar.style.display = "none";
|
||||
} else {
|
||||
$(".exit-fullscreen-button").replaceWith(originalExitButton);
|
||||
player.onDoubleClick_ = onPlayerDblClick;
|
||||
expandMenu.onmouseleave = undefined;
|
||||
originalExitButton.click();
|
||||
appLayout.classList.remove("pip");
|
||||
if (titlebar) titlebar.style.display = "flex";
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -97,9 +105,9 @@ function observeMenu(options) {
|
||||
"apiLoaded",
|
||||
() => {
|
||||
listenForToggle();
|
||||
// remove native listeners
|
||||
|
||||
cloneButton(".player-minimize-button").onclick = async () => {
|
||||
const isUsingNativePiP = await global.togglePictureInPicture();
|
||||
await global.togglePictureInPicture();
|
||||
setTimeout(() => $("#player").click());
|
||||
};
|
||||
|
||||
@ -115,4 +123,18 @@ function observeMenu(options) {
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = observeMenu;
|
||||
module.exports = (options) => {
|
||||
observeMenu(options);
|
||||
|
||||
if (options.hotkey) {
|
||||
const hotkeyEvent = toKeyEvent(options.hotkey);
|
||||
window.addEventListener("keydown", (event) => {
|
||||
if (
|
||||
keyEventAreEqual(event, hotkeyEvent) &&
|
||||
!$("ytmusic-search-box").opened
|
||||
) {
|
||||
togglePictureInPicture();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user