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

    Interface Command

    A registered command, from Commands.add. Disposing it removes it from the menu and the binding table; the id can be added again right away.

    The handle of one menu item and its keys. Its state (enabled, checked, busy, reason) is bound: functions given to Commands.add or Command.set are evaluated again in every full update pass (after a player state change only if they read a changed field of plugin.player.state or Scope.state) and only changes reach the player; a command without functions is left out of the passes. Its title, path, bindings and button cannot change in place; dispose the command (or a child Scope) and add it again. Disposing it, its scope or stopping the plugin removes the menu item, its keys and its bar button.

    Video ▸ Export… is greyed out until a file is open. set replaces the enabled field with a condition, which the player evaluates itself at every change, so the item follows the player without further code, also while the plugin is stopped.

    const exportCommand = plugin.commands.add({
    id: "export",
    path: ["@video", "Export…"],
    run: runExport,
    });
    exportCommand.set({ enabled: plugin.when.ready }); // evaluated by the player

    1.0.0

    interface Command {
        dispose(): Promise<void>;
        id: string;
        set(
            state: Partial<
                { [K in "busy"
                | "reason"]: Bindable<CommandState[K]> } & {
                    enabled: Bindable<boolean> | Condition;
                    checked: Bindable<boolean | null> | Condition;
                },
            >,
        ): void;
        ready: Promise<void>;
    }

    Hierarchy (View Summary)

    Index
    • Release the resource. Resolves once the player confirmed the release (or immediately for purely local resources). Never rejects.

      Returns Promise<void>

      Never.

      A "Turn feature off" item removes the feature's own menu item at once, before the plugin stops. dispose takes the command out of the menu and the binding table and resolves once the player confirmed it; the id can be added again later.

      const extra = plugin.commands.add({ id: "extra", path: ["Tools", "Extra"], run() {} });
      plugin.commands.add({
      id: "extra-off",
      path: ["Tools", "Turn extra off"],
      run: () => extra.dispose(), // never rejects
      });

      1.0.0

    • Replace some state fields (values or functions). Last write wins.

      Parameters

      Returns void

      Only this command is evaluated again, not every binding and command of the plugin. Several calls within one microtask send one update. A function field makes the command take part in the update passes from then on. A binding that reads a plugin variable changed together with set outside a handler the SDK runs (a timer) is not refreshed by it: call Scope.update or keep that variable in Scope.state.

      The Export item shows as busy with "Exporting…" as its reason while the export runs, then returns to normal. set replaces only the fields it names and the SDK sends the new state to the player; a busy command's menu item and key do not run it again until it is set back.

      const exportCommand = plugin.commands.add({
      id: "export",
      path: ["@video", "Export…"],
      run: async () => {
      exportCommand.set({ busy: true, reason: "Exporting…" });
      try {
      await runExport();
      } finally {
      exportCommand.set({ busy: false, reason: null }); // also on failure
      }
      },
      });

      1.0.0

    id: string

    The local id given in CommandOptions.id.

    ready: Promise<void>

    Resolves when the host has registered the command. Rejects with conflict (path already taken), invalid or limit (more than 160 commands in this plugin, or 1024 in the whole player). You rarely need to await it: the refusal goes to Scope.onError. During activation the SDK, in the plugin's process, logs the refusal with the command id and the player's message, skips the command and lets the rest of the plugin activate; the error reaches onError once activation completes, so a listener added anywhere in activate hears it. startPlugin stays strict: there a refusal during activation fails it, so tests show the bad declaration. Any other failure during activation (no answer, for example) fails activation.

    Only the player's answer is skipped. What Commands.add checks itself still throws from add (an unknown @ menu id, more than 8 path segments, an order out of range, a malformed binding or one listed twice, a bad button, a reason text of the wrong shape, an id already declared), and fails activation unless the plugin catches it.

    conflict (rejects) Another command already has this menu path, or the path would be both a menu item and a submenu.

    invalid (rejects) The player refused the declaration.

    limit (rejects) More than 160 commands in this plugin, or 1024 in the player.