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

    Interface Mpv

    plugin.mpv: mpv's own commands and properties, sent to the player's mpv as they are.

    A plugin offers mpv's deband option, which the plugin API has no member for. set writes the property and get reads it back; the names and the values are mpv's.

    await plugin.mpv.set("deband", true);
    const on = await plugin.mpv.get("deband");
    await plugin.osd.show(on ? "Debanding on" : "Debanding off");

    The channel is the SDK's contract: four members, their errors, what is refused and who owns what. The names, the arguments and what they do are mpv's, as its manual describes them for the mpv the player ships (commands, properties, options); they can change with a player version, which the SDK does not track. Prefer a typed member where one exists (Player, Scope.video, Scope.subtitles): it is checked, tested by TestHost and reaches snapshots and exports, which a filter added here does not.

    Refused with code refused (the message names the command or property and why): what starts a program, loads scripts or configuration, opens a control channel, makes the player write or delete files, ends the player, drives its keyboard and mouse, reaches the clipboard, or changes what the player manages itself (the source and the playlist, the position, the tracks, the output, the window, the subtitle style, the renderer options of Scope.video, its own filters). A plugin does the first four with Node; the last has a typed member. Reading is not refused, except the clipboard. The full table is in mpv.

    Filters: ["vf", "add", "@label:…"] (and af; add, pre, toggle, remove) with a label of the plugin's own, not starting with vestra- and not all. A labelled filter belongs to the plugin that added it: another plugin cannot change it (conflict), and the player removes it when the plugin stops. The player's own filters (the typed chains of Scope.video, the upscaler, motion smoothing) stay in the chain beside it.

    A property a plugin set keeps its value after the plugin stops, until the player quits; a plugin that wants it back sets it back. Observers end with the plugin. A filter or an observer keeps the plugin running from the moment it is added for the rest of that run, also after it is removed: the player judges again at the plugin's next start.

    mpv

    1.8.0

    interface Mpv {
        command(args: readonly (string | number | boolean)[]): Promise<MpvValue>;
        get(name: string): Promise<MpvValue>;
        set(name: string, value: MpvValue): Promise<void>;
        observe(name: string, listener: (value: MpvValue) => void): Disposable;
    }
    Index
    • Run an mpv command: its name, then its arguments, as mpv's manual lists them. Resolves with the command's result (null for most).

      Parameters

      • args: readonly (string | number | boolean)[]

        The command's name and its arguments: strings, numbers or booleans. The first is the command itself: mpv would take a prefix word (no-osd, async, raw…) off the front and run what follows, so the channel refuses one there (invalid). Arguments are not expanded (${property} stays text).

      Returns Promise<MpvValue>

      What the command returns.

      A plugin sharpens the picture with an FFmpeg filter the typed chain does not offer, and takes it out when the user switches it off. The label makes the filter the plugin's: the player removes it by itself when the plugin stops.

      await plugin.mpv.command(["vf", "add", "@crisp:lavfi=[cas=strength=0.6]"]);
      // later
      await plugin.mpv.command(["vf", "remove", "@crisp"]);

      invalid (rejects) Not an array of a name and up to 31 arguments, or an argument that is not a string, number or boolean.

      refused (rejects) A command the channel does not carry; the message names it and why.

      conflict (rejects) A filter label another plugin owns.

      backend (rejects) mpv failed the command; message is mpv's error ("mpv: invalid parameter").

      1.8.0

    • Read an mpv property now.

      Parameters

      • name: string

        The property, as mpv names it ("estimated-vf-fps", "video-params/w").

      Returns Promise<MpvValue>

      Its value.

      A statistics panel reads which hardware decoder mpv uses now. get resolves with mpv's value: here a string, "no" without one.

      const decoder = await plugin.mpv.get("hwdec-current");
      await plugin.osd.show("Decoder: {}", [String(decoder)]);

      invalid (rejects) Not a property name.

      refused (rejects) The clipboard's properties.

      backend (rejects) mpv has no such property, or it has no value now ("mpv: property not found", "mpv: property unavailable").

      1.8.0

    • Set an mpv property (or option). It keeps the value after the plugin stops, until the player quits.

      Parameters

      • name: string

        The property, as mpv names it.

      • value: MpvValue

        Its new value, in the type mpv has for it.

      Returns Promise<void>

      A plugin switches mpv's scaler and puts the old one back when its panel closes. The value is read first, since set does not undo itself.

      const before = await plugin.mpv.get("scale");
      await plugin.mpv.set("scale", "ewa_lanczossharp");
      // when the panel closes
      await plugin.mpv.set("scale", before);

      invalid (rejects) Not a property name, or no value.

      refused (rejects) A property the channel does not carry; the message names it and why.

      backend (rejects) mpv refused the value or has no such property; message is mpv's error.

      1.8.0

    • Hear an mpv property's value now and after each change. The player sends the newest value at most every 100 ms. From the first listener on the player keeps the plugin running for the rest of the run, also after the handle is disposed. As after every handler, an update pass follows each call of the listener.

      Parameters

      • name: string

        The property, as mpv names it.

      • listener: (value: MpvValue) => void

        Receives the value: first the current one, then each change. A listener added while the plugin already observes the property gets its current value too, just after observe returns.

      Returns Disposable

      A handle that stops listening; it is disposed with the scope.

      A panel shows the frame rate mpv measures behind its filter chain. The listener runs with the current value and again whenever it changes; a failure to observe goes to plugin.onError.

      plugin.mpv.observe("estimated-vf-fps", (fps) => {
      panel.set({ fps: typeof fps === "number" ? fps.toFixed(1) : "—" });
      });

      invalid (throws) Not a property name, or no listener.

      refused (throws) The clipboard's properties.

      limit (through onError) More than 64 properties observed by this plugin.

      1.8.0