mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-15 20:31:46 +00:00
fix: don't create play pause method unneccessarily
This commit is contained in:
@ -21,7 +21,7 @@ function _registerLocalShortcut(win, shortcut, action) {
|
|||||||
|
|
||||||
function registerShortcuts(win, options) {
|
function registerShortcuts(win, options) {
|
||||||
const songControls = getSongControls(win);
|
const songControls = getSongControls(win);
|
||||||
const { play, pause, playPause, next, previous, search } = songControls;
|
const { playPause, next, previous, search } = songControls;
|
||||||
|
|
||||||
_registerGlobalShortcut(win.webContents, "MediaPlayPause", playPause);
|
_registerGlobalShortcut(win.webContents, "MediaPlayPause", playPause);
|
||||||
_registerGlobalShortcut(win.webContents, "MediaNextTrack", next);
|
_registerGlobalShortcut(win.webContents, "MediaNextTrack", next);
|
||||||
@ -29,12 +29,14 @@ function registerShortcuts(win, options) {
|
|||||||
_registerLocalShortcut(win, "CommandOrControl+F", search);
|
_registerLocalShortcut(win, "CommandOrControl+F", search);
|
||||||
_registerLocalShortcut(win, "CommandOrControl+L", search);
|
_registerLocalShortcut(win, "CommandOrControl+L", search);
|
||||||
registerCallback(songInfo => {
|
registerCallback(songInfo => {
|
||||||
player.metadata = {
|
if (player) {
|
||||||
'mpris:length': songInfo.songDuration * 60 * 1000 * 1000, // In microseconds
|
player.metadata = {
|
||||||
'mpris:artUrl': songInfo.imageSrc,
|
'mpris:length': songInfo.songDuration * 60 * 1000 * 1000, // In microseconds
|
||||||
'xesam:title': songInfo.title,
|
'mpris:artUrl': songInfo.imageSrc,
|
||||||
'xesam:artist': songInfo.artist
|
'xesam:title': songInfo.title,
|
||||||
};
|
'xesam:artist': songInfo.artist
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -46,16 +48,17 @@ function registerShortcuts(win, options) {
|
|||||||
win.setSkipTaskbar(false);
|
win.setSkipTaskbar(false);
|
||||||
win.show();
|
win.show();
|
||||||
});
|
});
|
||||||
MPRISPlayer.on("playPause", () => {
|
|
||||||
console.log("Playpause");
|
|
||||||
})
|
|
||||||
MPRISPlayer.on("play", () => {
|
MPRISPlayer.on("play", () => {
|
||||||
player.playbackStatus = 'Playing';
|
if (MPRISPlayer.playbackStatus !== 'Playing') {
|
||||||
play()
|
MPRISPlayer.playbackStatus = 'Playing';
|
||||||
|
playPause()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
MPRISPlayer.on("pause", () => {
|
MPRISPlayer.on("pause", () => {
|
||||||
player.playbackStatus = 'Paused';
|
if (MPRISPlayer.playbackStatus === 'Playing') {
|
||||||
pause()
|
MPRISPlayer.playbackStatus = 'Paused';
|
||||||
|
playPause()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
MPRISPlayer.on("next", () => {
|
MPRISPlayer.on("next", () => {
|
||||||
next()
|
next()
|
||||||
|
|||||||
@ -15,22 +15,4 @@ module.exports = () => {
|
|||||||
videoStream.pause();
|
videoStream.pause();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcRenderer.on("play", () => {
|
|
||||||
if (!videoStream) {
|
|
||||||
videoStream = document.querySelector(".video-stream");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (videoStream.paused) videoStream.play();
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcRenderer.on("pause", () => {
|
|
||||||
if (!videoStream) {
|
|
||||||
videoStream = document.querySelector(".video-stream");
|
|
||||||
}
|
|
||||||
|
|
||||||
videoStream.yns_pause ?
|
|
||||||
videoStream.yns_pause() :
|
|
||||||
videoStream.pause();
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user