Skip to content

Commit

Permalink
feat(command): dedicated command for play and pause
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenlx committed Apr 9, 2024
1 parent 0249053 commit 9680f03
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions apps/app/src/media-note/command/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ const createMediaCommands = (plugin: MxPlugin): Controls[] => [
media.paused = !media.paused;
},
},
{
id: "play",
label: "Play",
icon: "play",
action: (media) => {
media.play();
},
},
{
id: "pause",
label: "Pause",
icon: "pause",
action: (media) => {
media.pause();
},
},
...[0.5, 1, 2, 5, 10, 30, 60].flatMap((sec): Controls[] => [
{
id: `forward-${sec}s`,
Expand Down Expand Up @@ -83,17 +99,17 @@ function speed(plugin: MxPlugin): Controls[] {
...speedOptions
.filter((s) => s > 1)
.map((speed): Controls => {
let repeated = false;
let repeating = false;
const { callback } = handleRepeatHotkey<[MediaPlayerInstance]>(plugin, {
onKeyDown(evt, media) {
if (evt.repeat) {
repeated = true;
if (evt.repeat && !repeating) {
repeating = true;
media.playbackRate = speed;
notifyManualHide(`Fast forwarding at ${speed}x`);
}
},
onKeyUp(_evt, media) {
if (repeated) {
if (repeating) {
media.playbackRate = 1;
notice?.hide();
}
Expand Down

0 comments on commit 9680f03

Please sign in to comment.