add bindMediaKey to options

This commit is contained in:
Michael C 2022-01-27 01:43:40 -05:00
parent 6d0d533fa7
commit 876b55dcc1
No known key found for this signature in database
GPG key ID: FFB04FB3B878B7B4
4 changed files with 25 additions and 2 deletions

View file

@ -918,5 +918,11 @@
},
"youtubeKeybindWarning": {
"message": "This is a built-in YouTube shortcut. Are you sure you want to use it?"
},
"bindMediaKey": {
"message": "Play/Pause Current Video with Media Keys"
},
"bindMediaKeyDescription": {
"message": "Enable this if your media keys stop working after the audio notification is played."
}
}

View file

@ -263,6 +263,20 @@
<div class="small-description">__MSG_audioNotificationDescription__</div>
</div>
<div data-type="toggle" data-sync="bindMediaKey" data-dependent-on="audioNotificationOnSkip">
<div class="switch-container">
<label class="switch">
<input id="bindMediaKey" type="checkbox" checked>
<span class="slider round"></span>
</label>
<label class="switch-label" for="bindMediaKey">
__MSG_bindMediaKey__
</label>
</div>
<div class="small-description">__MSG_bindMediaKeyDescription__</div>
</div>
<div data-type="toggle" data-sync="showTimeWithSkips">
<div class="switch-container">

View file

@ -36,7 +36,8 @@ interface SBConfig {
serverAddress: string,
minDuration: number,
skipNoticeDuration: number,
audioNotificationOnSkip,
audioNotificationOnSkip: boolean,
bindMediaKey: boolean,
checkForUnlistedVideos: boolean,
testingServer: boolean,
refetchWhenNotFound: boolean,
@ -198,6 +199,7 @@ const Config: SBObject = {
minDuration: 0,
skipNoticeDuration: 4,
audioNotificationOnSkip: false,
bindMediaKey: false,
checkForUnlistedVideos: false,
testingServer: false,
refetchWhenNotFound: true,

View file

@ -1273,7 +1273,8 @@ 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();
window.addEventListener("keydown", mediaPauseListener);
if (Config.config.audioNotificationOnSkip && Config.config.bindMediaKey)
window.addEventListener("keydown", mediaPauseListener);
}
if (!autoSkip