Skip to content

Commit

Permalink
feat: add volume control (#1107)
Browse files Browse the repository at this point in the history
  • Loading branch information
bk7312 authored May 24, 2024
1 parent 7d9be29 commit aea4f32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,10 @@ function runAction(action, value, e) {
pause(v);
} else if (action === "muted") {
muted(v);
} else if (action === "louder") {
volumeUp(v, value);
} else if (action === "softer") {
volumeDown(v, value);
} else if (action === "mark") {
setMark(v);
} else if (action === "jump") {
Expand Down Expand Up @@ -875,6 +879,14 @@ function muted(v) {
v.muted = v.muted !== true;
}

function volumeUp(v, value) {
v.volume = Math.min(1, (v.volume + value).toFixed(2));
}

function volumeDown(v, value) {
v.volume = Math.max(0, (v.volume - value).toFixed(2));
}

function setMark(v) {
log("Adding marker", 5);
v.vsc.mark = v.currentTime;
Expand Down
2 changes: 2 additions & 0 deletions options.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ function add_shortcut() {
<option value="reset">Reset speed</option>
<option value="fast">Preferred speed</option>
<option value="muted">Mute</option>
<option value="softer">Decrease volume</option>
<option value="louder">Increase volume</option>
<option value="pause">Pause</option>
<option value="mark">Set marker</option>
<option value="jump">Jump to marker</option>
Expand Down

0 comments on commit aea4f32

Please sign in to comment.