forked from th-ch/youtube-music
-
Notifications
You must be signed in to change notification settings - Fork 1
/
song-controls.js
52 lines (51 loc) · 1.4 KB
/
song-controls.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// This is used for to control the songs
const pressKey = (window, key, modifiers = []) => {
window.webContents.sendInputEvent({
type: "keydown",
modifiers,
keyCode: key,
});
};
module.exports = (win) => {
return {
// Playback
previous: () => pressKey(win, "k"),
next: () => pressKey(win, "j"),
playPause: () => win.webContents.send("playPause"),
like: () => pressKey(win, "_"),
dislike: () => pressKey(win, "+"),
go10sBack: () => pressKey(win, "h"),
go10sForward: () => pressKey(win, "l"),
go1sBack: () => pressKey(win, "h", ["shift"]),
go1sForward: () => pressKey(win, "l", ["shift"]),
shuffle: () => pressKey(win, "s"),
switchRepeat: () => pressKey(win, "r"),
// General
volumeMinus10: () => pressKey(win, "-"),
volumePlus10: () => pressKey(win, "="),
dislikeAndNext: () => pressKey(win, "-", ["shift"]),
like: () => pressKey(win, "=", ["shift"]),
fullscreen: () => pressKey(win, "f"),
muteUnmute: () => pressKey(win, "m"),
maximizeMinimisePlayer: () => pressKey(win, "q"),
// Navigation
goToHome: () => {
pressKey(win, "g");
pressKey(win, "h");
},
goToLibrary: () => {
pressKey(win, "g");
pressKey(win, "l");
},
goToHotlist: () => {
pressKey(win, "g");
pressKey(win, "t");
},
goToSettings: () => {
pressKey(win, "g");
pressKey(win, ",");
},
search: () => pressKey(win, "/"),
showShortcuts: () => pressKey(win, "/", ["shift"]),
};
};