Skip to content

Commit

Permalink
feat(player): full screen toggle command
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenlx committed Feb 1, 2024
1 parent d4773cf commit 744b8b2
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions apps/app/src/media-note/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ interface Controls {
label: string;
icon: string;
repeat?: boolean;
check?: (media: MediaPlayerInstance) => boolean;
action: (media: MediaPlayerInstance) => void;
}

Expand Down Expand Up @@ -122,27 +123,24 @@ const commands: Controls[] = [
},
},
{
id: "enter-fullscreen",
label: "Fullscreen",
id: "toggle-fullscreen",
label: "Enter/exit fullscreen",
icon: "expand",
check: media => media.state.canFullscreen,
action: (media) => {
media.enterFullscreen();
},
},
{
id: "exit-fullscreen",
label: "Exit Fullscreen",
icon: "expand",
action: (media) => {
media.exitFullscreen();
if (media.state.fullscreen) {
media.exitFullscreen();
} else {
media.enterFullscreen();
}
},
},
];

export function registerControlCommands(plugin: MxPlugin) {
const { workspace } = plugin.app;

commands.forEach(({ id, label, icon, action, repeat }) => {
commands.forEach(({ id, label, icon, action, repeat, check }) => {
plugin.addCommand({
id: `${id}-player`,
name: `${label} on current media`,
Expand Down Expand Up @@ -172,6 +170,7 @@ export function registerControlCommands(plugin: MxPlugin) {
if (!mediaView) return false;
const player = mediaView.view.store.getState().player;
if (!player) return false;
if (check && !check(player)) return false;
if (checking) return true;
action(player);
},
Expand Down

0 comments on commit 744b8b2

Please sign in to comment.