mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-12 02:51:46 +00:00
directly playPause video element
This commit is contained in:
@ -5,6 +5,8 @@ const { remote } = require("electron");
|
||||
const config = require("./config");
|
||||
const { fileExists } = require("./plugins/utils");
|
||||
const setupFrontLogger = require("./providers/front-logger");
|
||||
const setupSongControl = require("./providers/song-controls-front");
|
||||
const setupSongInfo = require("./providers/song-info-front");
|
||||
|
||||
const plugins = config.plugins.getEnabled();
|
||||
|
||||
@ -37,8 +39,10 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
});
|
||||
|
||||
// inject song-info provider
|
||||
const songInfoProviderPath = path.join(__dirname, "providers", "song-info-front.js")
|
||||
fileExists(songInfoProviderPath, require(songInfoProviderPath));
|
||||
setupSongInfo();
|
||||
|
||||
// inject song-control provider
|
||||
setupSongControl();
|
||||
|
||||
// inject front logger
|
||||
setupFrontLogger();
|
||||
|
||||
18
providers/song-controls-front.js
Normal file
18
providers/song-controls-front.js
Normal file
@ -0,0 +1,18 @@
|
||||
const { ipcRenderer } = require("electron");
|
||||
|
||||
let videoStream;
|
||||
module.exports = () => {
|
||||
videoStream = document.querySelector(".video-stream");
|
||||
|
||||
ipcRenderer.on("playPause", () => {
|
||||
if (!videoStream) {
|
||||
videoStream = document.querySelector(".video-stream");
|
||||
}
|
||||
|
||||
if (videoStream.paused) {
|
||||
videoStream.play();
|
||||
} else {
|
||||
videoStream.yns_pause();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -12,7 +12,7 @@ module.exports = (win) => {
|
||||
// Playback
|
||||
previous: () => pressKey(win, "k"),
|
||||
next: () => pressKey(win, "j"),
|
||||
playPause: () => pressKey(win, "space"),
|
||||
playPause: () => win.webContents.send("playPause"),
|
||||
like: () => pressKey(win, "_"),
|
||||
dislike: () => pressKey(win, "+"),
|
||||
go10sBack: () => pressKey(win, "h"),
|
||||
|
||||
Reference in New Issue
Block a user