@vestra-player/sdk - v1.11.3
    Preparing search index...

    Interface CommandOptions

    The declaration passed to Commands.add.

    Menu order: siblings sort by order ascending; a submenu sits where its first command sits and takes that command's group. Equal orders sort by plugin id, then declaration order, never by title. group only draws separators, so keep a group's orders contiguous. Recommended top-level ranges: open 100–199, domain 200–699 (playback, subtitles, video, audio…), screen 700–799, windows 800–819, settings-main 820–999 (Tools ▸, Options…, Quit); put a tool into Tools ▸ (@tools) rather than the top level.

    Built-in menus keep their place. The built-in top-level menus (MenuId) sit at fixed orders, whatever is inside them: Open 110, Playback 200, Subtitles 300, Video 400, Audio 500, Screen 710, Tools 820, Settings 830, Reset 840. Tools and Settings are drawn in the separator group of Options… and Quit (settings-main) and Reset in Settings' group, whatever groups the items inside declare. Like every built-in menu, Tools, Settings and Reset show only when a command is in them. This holds whether the path names the menu by id (["@video", "Blur"]) or by its key (["Video", "Blur"]), so a plugin's item never moves the player's menu. Directly inside a built-in menu, order 0 (the default) sorts after every other order: an item without order goes at the end, after the player's own items (which all use 100 or more). Give a positive order to sit between them (the player's items in menu order are in Built-in commands), or a negative one to come first. Deeper levels (a plugin's own submenu) have no such rule.

    Commands.add throws invalid synchronously for a bad path, order or binding; the player refuses an empty or overlong text, a control character or whitespace at either end (COMMAND_LIMITS) with invalid (through ready). The same path registered twice, or a path that is both an item and a submenu, fails with conflict (through ready).

    interface CommandOptions {
        id: string;
        path?: (string | Text)[];
        title?: string | Text;
        category?: string | Text;
        home?: string;
        order?: number;
        group?: string;
        radio?: boolean;
        bindings?: string[];
        focus?: "panel";
        repeat?: boolean;
        button?: CommandButton;
        destructive?: boolean;
        enabled?: Bindable<boolean> | Condition;
        checked?: Condition | Bindable<boolean | null>;
        busy?: Bindable<boolean>;
        reason?: Bindable<(TextValue | null)>;
        run(): unknown;
    }
    Index
    • Run the command (menu item, binding, panel menu or host.command(id).run() in tests). It may return a promise; errors and rejections go to Scope.onError, and bound values are re-evaluated when it returns and when its promise settles.

      Returns unknown

    id: string

    Local id, unique within the plugin (the global id is <manifest id>/<id>).

    path?: (string | Text)[]

    Menu path including the leaf, 1–8 segments, e.g. ["@video", "Adjust picture…"]; one segment is a top-level item. Omit it for a command that is not in the main menu (bindings and panel menus only); title is then required.

    Segments are English source text, and menus merge by them: commands of different plugins with the same leading segments share a submenu. The player shows each segment and the title in the interface language from the declaring plugin's catalog (locales/<lang>.po, see the i18n guide); the player's own menus (Open, Playback, Subtitles, Video, Audio, Screen, Settings, Reset, Tools, and Playback ▸ Speed, Playback ▸ Seek) always show the player's words. A built-in menu can also be named by its id, @ plus a MenuId: @open, @playback, @subtitles, @video, @audio, @screen, @settings, @reset or @tools. Only the first segment is read as an id; an unknown id, or an id with nothing after it, fails with invalid.

    A segment that mixes words with data (a track number, a count) is a Text: plugin.i18n.text("Track {} ({})", [n, codec]). The menu shows it translated and filled in; it merges by its English rendering ("Track 2 (opus)").

    "Blur" appears in the Video menu and "Track 2 (opus)" under Audio ▸ Audio Track, both in the user's language. @video and @audio name the built-in menus by id; "Audio Track" is a submenu key that merges with any other plugin's same key; the text() segment is translated with the plugin's catalog and then filled in with the number and codec.

    plugin.commands.add({ id: "blur", path: ["@video", "Blur"], run: toggle });
    const { text } = plugin.i18n;
    // A segment with data: translated as "Track {} ({})", then filled in.
    plugin.commands.add({
    id: "track-2",
    path: ["@audio", "Audio Track", text("Track {} ({})", [2, "opus"])],
    run: select,
    });
    title?: string | Text

    Menu label (English source text, shown translated, or a Text); defaults to the last path segment.

    category?: string | Text

    What the command is about, in a word or two ("Subtitle Sync", "Picture"): English source text, shown translated like title, or a Text. The player's command palette (Ctrl+Shift+P, ⌘⇧P on macOS) and lists of commands name a command Category: Title, so a short title such as "Earlier 0.5 s", "Off" or "90°" still says what it changes once it is out of the menu. Without it the player uses the menu path above the item, then the plugin's name.

    1–80 UTF-8 bytes (a text value counted by its English rendering), no control characters, no whitespace at either end (COMMAND_LIMITS.categoryBytes); the player refuses anything else with invalid.

    The palette lists "Subtitle Sync: Earlier 0.5 s" and "Subtitle Sync: Later 0.5 s"; without a category both would read as a bare "Earlier 0.5 s", indistinguishable from an audio delay command of the same name.

    for (const [id, title, seconds] of [
    ["sync-earlier", "Earlier 0.5 s", -0.5],
    ["sync-later", "Later 0.5 s", 0.5],
    ] as const)
    plugin.commands.add({
    id,
    title,
    category: "Subtitle Sync", // the palette reads "Subtitle Sync: Earlier 0.5 s"
    bindings: [id === "sync-earlier" ? "." : ","],
    run: () => shift(seconds),
    });

    0.7.6

    1.6.4

    home?: string

    The id of this plugin's command that opens the window or panel where this command's control lives ("tune" for a Subtitle Tuning… command whose window has the sync slider). The player's command palette shows that place next to the command. A local id, like id: ASCII letters, digits, ., _ and -, 1–128 bytes; the player refuses anything else with invalid. The command it names need not be registered yet; while it is not, the palette shows the place it would show without home: the menu path above the item, "Menu" for a top-level item, nothing for a command outside the menu.

    The palette row for "Subtitle Sync: Earlier 0.5 s" also says where the same setting can be changed by hand: the Subtitle Tuning window that the tune command opens.

    plugin.commands.add({
    id: "tune",
    path: ["@subtitles", "Subtitle Tuning…"],
    run: () => tuning.show(),
    });
    plugin.commands.add({
    id: "sync-earlier",
    title: "Earlier 0.5 s",
    category: "Subtitle Sync",
    home: "tune", // the palette shows "Subtitle Tuning" as its place
    run: () => shift(-0.5),
    });

    0.7.6

    1.6.4

    order?: number

    Sibling order in the menu, ascending (integer, default 0). A submenu sits where its first command sits, except a built-in menu, which keeps its fixed place. Directly inside a built-in menu, 0 (the default) sorts last. Equal orders: plugin id, then declaration order. Range ±1,000,000. See CommandOptions for the menu order rules.

    group?: string

    Separator label: a line is drawn between adjacent items of different groups. Default "domain".

    radio?: boolean

    Draw checked as a radio dot instead of a check mark.

    bindings?: string[]

    Default input bindings, e.g. ["Space"], ["Ctrl+O", "F3"], ["Mouse:WheelUp"].

    Syntax: {Modifier "+"} Input, modifiers in the order Ctrl, Alt, Shift, Cmd, each at most once. Inputs: A–Z, 0–9, F1–F24, Space, Enter, Tab, Escape, Backspace, Delete, Insert, Home, End, PageUp, PageDown, ArrowLeft/Right/Up/Down, Plus, any other single symbol as typed (">", not "Shift+."), Numpad0–Numpad9, NumpadPlus, NumpadMinus, NumpadMultiply, NumpadDivide, NumpadEnter, NumpadDecimal, the video-area mouse inputs Mouse:LeftClick, Mouse:LeftDoubleClick[:LeftHalf|:RightHalf], Mouse:MiddleClick, Mouse:WheelUp/Down/Left/Right, and the side buttons Mouse:X1 (back), Mouse:X2 (forward), anywhere in the main window or the floating sidebar window, except while a menu is open.

    Platforms: on macOS Ctrl+X fires for both ⌃X and ⌘X while Cmd+X means ⌘X only; on Windows Cmd is the Windows logo key, so write Ctrl+… for bindings that work on both. Avoid the keys the system takes first.

    Conflicts are not errors: the user's overrides win, then the player's own commands, then the plugin loaded first; a shadowed binding takes effect when the winner goes away. Up to 16 bindings.

    focus?: "panel"

    "panel": the bindings apply only while this plugin's panel has focus.

    repeat?: boolean

    Fire again on keyboard auto-repeat while the key is held. Default false.

    button?: CommandButton

    A button for this command on the bottom bar: an icon and a place, { icon: "store", order: 200 }. Needs a path: the menu entry is where the command stays reachable wherever the button is (the strip or its » menu). See CommandButton for where it shows, what it shows and the limits. Fails with invalid for an unknown icon name, an order outside 0–999 or a button without a path.

    destructive?: boolean

    The command cannot be undone: it deletes or clears the user's data, closes what is open or quits (default false). When another plugin runs it through Commands.run, the player asks the user first; a menu pick, a key or the command palette runs it as before.

    0.7.6

    1.7.9

    enabled?: Bindable<boolean> | Condition

    Whether the command can run (default true): a value, a function, or a Condition the player evaluates (plugin.when).

    checked?: Condition | Bindable<boolean | null>

    Check mark (or radio dot with radio); null (default) draws none. A Condition (plugin.when) draws the mark while it holds.

    busy?: Bindable<boolean>

    Busy state (default false); the player does not call run while busy.

    reason?: Bindable<(TextValue | null)>

    Why the command is disabled or busy (shown to the user): English source text, or a Text for one with data in it. With an enabled Condition the player shows it only while the condition is false or the command is busy, so a fixed text is enough.