force listen for mediaKeys

This commit is contained in:
Michael C 2022-01-27 00:53:30 -05:00
parent 9457aff44f
commit 6d0d533fa7
No known key found for this signature in database
GPG key ID: FFB04FB3B878B7B4
3 changed files with 6 additions and 33676 deletions

33671
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -20,7 +20,6 @@
"@types/firefox-webext-browser": "70.0.1",
"@types/jest": "^24.0.23",
"@types/jquery": "^3.3.31",
"@types/wicg-mediasession": "^1.1.3",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.9.1",
"chromedriver": "^92.0.0",

View file

@ -1273,10 +1273,7 @@ function skipToTime({v, skipTime, skippingSegments, openNotice, forceAutoSkip, u
const beep = new Audio(chrome.runtime.getURL("icons/beep.ogg"));
beep.volume = video.volume * 0.1;
beep.play();
beep.controls = false;
// hijack media function
navigator.mediaSession.setActionHandler('play', () => video.play())
navigator.mediaSession.setActionHandler("pause", () => video.pause())
window.addEventListener("keydown", mediaPauseListener);
}
if (!autoSkip
@ -2041,4 +2038,9 @@ function checkForPreloadedSegment() {
}
}
}
}
function mediaPauseListener(e: KeyboardEvent) {
if (e.key === "MediaPlayPause")
video?.paused ? video.play() : video.pause();
}