mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
Merge pull request #519 from th-ch/skip-silences-plugin
Add "Skip silences" plugin
This commit is contained in:
@ -68,8 +68,8 @@
|
|||||||
"@ffmpeg/ffmpeg": "^0.10.0",
|
"@ffmpeg/ffmpeg": "^0.10.0",
|
||||||
"async-mutex": "^0.3.2",
|
"async-mutex": "^0.3.2",
|
||||||
"browser-id3-writer": "^4.4.0",
|
"browser-id3-writer": "^4.4.0",
|
||||||
"custom-electron-prompt": "^1.3.1",
|
|
||||||
"chokidar": "^3.5.2",
|
"chokidar": "^3.5.2",
|
||||||
|
"custom-electron-prompt": "^1.3.1",
|
||||||
"custom-electron-titlebar": "^3.2.7",
|
"custom-electron-titlebar": "^3.2.7",
|
||||||
"discord-rpc": "^3.2.0",
|
"discord-rpc": "^3.2.0",
|
||||||
"electron-better-web-request": "^1.0.1",
|
"electron-better-web-request": "^1.0.1",
|
||||||
@ -80,6 +80,7 @@
|
|||||||
"electron-unhandled": "^3.0.2",
|
"electron-unhandled": "^3.0.2",
|
||||||
"electron-updater": "^4.6.1",
|
"electron-updater": "^4.6.1",
|
||||||
"filenamify": "^4.3.0",
|
"filenamify": "^4.3.0",
|
||||||
|
"hark": "^1.2.3",
|
||||||
"md5": "^2.3.0",
|
"md5": "^2.3.0",
|
||||||
"mpris-service": "^2.1.2",
|
"mpris-service": "^2.1.2",
|
||||||
"node-fetch": "^2.6.6",
|
"node-fetch": "^2.6.6",
|
||||||
|
|||||||
35
plugins/skip-silences/front.js
Normal file
35
plugins/skip-silences/front.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
const hark = require("hark/hark.bundle.js");
|
||||||
|
|
||||||
|
module.exports = () => {
|
||||||
|
let isSilent = false;
|
||||||
|
|
||||||
|
document.addEventListener("apiLoaded", (apiEvent) => {
|
||||||
|
const video = document.querySelector("video");
|
||||||
|
const speechEvents = hark(video, {
|
||||||
|
threshold: -90, // dB (-100 = absolute silence, 0 = loudest)
|
||||||
|
interval: 2, // ms
|
||||||
|
});
|
||||||
|
const skipSilence = () => {
|
||||||
|
if (isSilent && !video.paused) {
|
||||||
|
video.currentTime += 0.2; // in s
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
speechEvents.on("speaking", function () {
|
||||||
|
isSilent = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
speechEvents.on("stopped_speaking", function () {
|
||||||
|
isSilent = true;
|
||||||
|
skipSilence();
|
||||||
|
});
|
||||||
|
|
||||||
|
video.addEventListener("play", function () {
|
||||||
|
skipSilence();
|
||||||
|
});
|
||||||
|
|
||||||
|
video.addEventListener("seeked", function () {
|
||||||
|
skipSilence();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
12
yarn.lock
12
yarn.lock
@ -4575,6 +4575,13 @@ hard-rejection@^2.1.0:
|
|||||||
resolved "https://registry.yarnpkg.com/hard-rejection/-/hard-rejection-2.1.0.tgz#1c6eda5c1685c63942766d79bb40ae773cecd883"
|
resolved "https://registry.yarnpkg.com/hard-rejection/-/hard-rejection-2.1.0.tgz#1c6eda5c1685c63942766d79bb40ae773cecd883"
|
||||||
integrity sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==
|
integrity sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==
|
||||||
|
|
||||||
|
hark@^1.2.3:
|
||||||
|
version "1.2.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/hark/-/hark-1.2.3.tgz#959981400f561be5580ecd4321a9f55b16bacbd0"
|
||||||
|
integrity sha512-u68vz9SCa38ESiFJSDjqK8XbXqWzyot7Cj6Y2b6jk2NJ+II3MY2dIrLMg/kjtIAun4Y1DHF/20hfx4rq1G5GMg==
|
||||||
|
dependencies:
|
||||||
|
wildemitter "^1.2.0"
|
||||||
|
|
||||||
has-ansi@^2.0.0:
|
has-ansi@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91"
|
resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91"
|
||||||
@ -8614,6 +8621,11 @@ widest-line@^3.1.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
string-width "^4.0.0"
|
string-width "^4.0.0"
|
||||||
|
|
||||||
|
wildemitter@^1.2.0:
|
||||||
|
version "1.2.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/wildemitter/-/wildemitter-1.2.1.tgz#9da3b5ca498e4378628d1783145493c70a10b774"
|
||||||
|
integrity sha512-UMmSUoIQSir+XbBpTxOTS53uJ8s/lVhADCkEbhfRjUGFDPme/XGOb0sBWLx5sTz7Wx/2+TlAw1eK9O5lw5PiEw==
|
||||||
|
|
||||||
word-wrap@^1.2.3, word-wrap@~1.2.3:
|
word-wrap@^1.2.3, word-wrap@~1.2.3:
|
||||||
version "1.2.3"
|
version "1.2.3"
|
||||||
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
|
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
|
||||||
|
|||||||
Reference in New Issue
Block a user