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

    Interface Condition

    A condition on the player's own state, from Scope.when, for a command's enabled or checked. The player evaluates it, again on every change of that state, whether or not the plugin runs.

    Combine conditions with and, or and not; each returns a new condition and leaves the original as it was. A condition is data: it reads nothing in the plugin and keeps no listener, so a plugin whose menu state is made of conditions may be stopped while idle (lazy activation) and its menu stays current. A function (see Bindable) keeps working; one that reads plugin.player.state or another service's state keeps the plugin running so the SDK can evaluate it.

    "Save Snapshot" is greyed out with its reason unless a media file is open at a frame the player can capture. The condition is sent with the command and evaluated by the player, so the item follows playback even while the plugin is stopped; with an enabled condition the player shows the reason only while the item is disabled.

    const { when } = plugin;
    plugin.commands.add({
    id: "save",
    path: ["@video", "Save Snapshot"],
    enabled: when.can("snapshot").and(when.phase("ready", "ended"), when.stream.not()),
    reason: "No frame to capture", // shown only while disabled
    run: saveSnapshot,
    });

    1.5.40

    interface Condition {
        and(...others: Condition[]): Condition;
        or(...others: Condition[]): Condition;
        not(): Condition;
    }
    Index
    • True when this condition and every one of others hold.

      Parameters

      Returns Condition

      The item is enabled only while a file plays in fullscreen. and returns a new condition; when.playing itself is unchanged.

      const { when } = plugin;
      const playingFullscreen = when.playing.and(when.fullscreen);

      1.5.40

    • True when this condition or one of others holds.

      Parameters

      Returns Condition

      The item is enabled while a file plays or is paused. or returns a new condition that holds when either of the two holds.

      const { when } = plugin;
      const active = when.playing.or(when.paused);

      1.5.40

    • True when this condition does not hold.

      Returns Condition

      An "Enter Fullscreen" item is enabled only outside fullscreen. not returns the opposite condition; the player evaluates it on every window change.

      const { when } = plugin;
      const windowed = when.fullscreen.not();

      1.5.40