diff --git a/plugins/shortcuts/back.js b/plugins/shortcuts/back.js index cbbcc7ea..dc711da1 100644 --- a/plugins/shortcuts/back.js +++ b/plugins/shortcuts/back.js @@ -21,7 +21,7 @@ function _registerLocalShortcut(win, shortcut, action) { function registerShortcuts(win, options) { const songControls = getSongControls(win); - const { playPause, next, previous, search } = songControls; + const { play, pause, playPause, next, previous, search } = songControls; _registerGlobalShortcut(win.webContents, "MediaPlayPause", playPause); _registerGlobalShortcut(win.webContents, "MediaNextTrack", next); @@ -41,20 +41,21 @@ function registerShortcuts(win, options) { if (is.linux()) { try { const MPRISPlayer = setupMPRIS(); - player = MPRISPlayer + MPRISPlayer.on("raise", () => { win.setSkipTaskbar(false); win.show(); }); + MPRISPlayer.on("playPause", () => { + console.log("Playpause"); + }) MPRISPlayer.on("play", () => { - console.log('Event:', "play", arguments); player.playbackStatus = 'Playing'; - playPause() + play() }); MPRISPlayer.on("pause", () => { - console.log('Event:', "pause", arguments); player.playbackStatus = 'Paused'; - playPause() + pause() }); MPRISPlayer.on("next", () => { next() @@ -63,6 +64,8 @@ function registerShortcuts(win, options) { previous() }); + player = MPRISPlayer + } catch (e) { console.warn("Error in MPRIS", e); } diff --git a/providers/song-controls-front.js b/providers/song-controls-front.js index 1860e761..9283a0b8 100644 --- a/providers/song-controls-front.js +++ b/providers/song-controls-front.js @@ -15,4 +15,22 @@ module.exports = () => { 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(); + }); }; diff --git a/providers/song-controls.js b/providers/song-controls.js index 5d3ad953..27be8822 100644 --- a/providers/song-controls.js +++ b/providers/song-controls.js @@ -13,6 +13,8 @@ module.exports = (win) => { previous: () => pressKey(win, "k"), next: () => pressKey(win, "j"), playPause: () => win.webContents.send("playPause"), + play: () => win.webContents.send("play"), + pause: () => win.webContents.send("pause"), like: () => pressKey(win, "_"), dislike: () => pressKey(win, "+"), go10sBack: () => pressKey(win, "h"),