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

    Interface Plugin

    The object the player passes to a plugin's activate: the root Scope, plus the plugin's identity and data directory.

    Activation: the player starts one Node process per plugin, reads the initial player, window and timeline state, then calls activate(plugin). Registrations started during activation (commands, panels, resolvers, subscriptions) do not need to be awaited: the plugin is reported ready once they all succeed, and activation fails if activate throws or any of them fails. A command declaration the player refuses is the exception: the SDK logs and skips it, its ready rejects and Scope.onError hears it, the rest of the plugin activates (startPlugin still fails on it). The entry module must default-export activate. Do not await a run of your own command or a callback of your own view inside activate: the player holds them until the plugin is ready, so activate waits until the start timeout (60 s) and the plugin stops with failed.

    Stopping: the player first revokes everything the plugin owns on its side (menus, windows, panels, filters, subtitle layers, snapshots, jobs, resolvers, streams); pending requests then fail with disabled and the root scope is disposed for local cleanup (timers, signals, sockets). A process that has not exited after its grace is killed: 5 s (300 ms after a fault); at quit all plugins together get 1 s. Media the plugin opened with Player.open keeps playing.

    Tools ▸ Say hello, or Ctrl+H, shows "Hello from" and the plugin's id. The player imports main.ts, calls its default export with the Plugin object, and keeps the registrations made during activation; the manifest says only who the plugin is.

    import type { Plugin } from "@vestra-player/sdk";

    export default async function activate(plugin: Plugin) {
    plugin.commands.add({
    id: "hello",
    path: ["Tools", "Say hello"],
    bindings: ["Ctrl+H"], // a default the user can change
    run: () => plugin.osd.show("Hello from {}", [plugin.id]),
    });
    }

    The root scope: disposing it is what stopping the plugin does. Besides the modules of Scope, it carries the plugin's id and its dataDirectory.

    1.0.0

    interface Plugin {
        dispose(): Promise<void>;
        commands: Commands;
        when: When;
        windows: Windows;
        panels: Panels;
        dialogs: Dialogs;
        player: Player;
        video: {
            filter(id: string): VideoFilter;
            view(): VideoView;
            render(): RenderOptions;
            shaders(id?: string): VideoShaders;
            upscaling: VideoUpscaling;
            motion(engine: MotionEngine): VideoMotion;
        };
        audio: { filter(id: string): AudioFilter };
        subtitles: Subtitles;
        media: MediaCapture;
        resolvers: Resolvers;
        packages: Packages;
        osd: Osd;
        palette: Palette;
        host: Host;
        clipboard: Clipboard;
        power: Power;
        tools: Tools;
        storage: Storage;
        system: System;
        secrets: Secrets;
        mpv: Mpv;
        window: MainWindow;
        app: App;
        rendering: Rendering;
        bindings: Bindings;
        ui: Ui;
        timeline: Timeline;
        drops: Drops;
        appearance: Appearance;
        i18n: I18n;
        settings: Settings;
        wire: Wire;
        scope(): Scope;
        add<T extends Disposable>(item: T): T;
        onDispose(
            cleanup:
                | ((info?: DisposeInfo) => void | Promise<void>)
                | (() => void | Promise<void>),
        ): Disposable;
        onError(listener: (error: PluginError) => void): Disposable;
        update(): void;
        state<T extends object>(initial: T): T;
        id: string;
        dataDirectory: string;
        stopReason: StopReason | undefined;
        trigger(name?: string): Trigger;
    }

    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

    • A child scope; disposing it releases only what was created through it. The child is itself owned by this scope.

      Returns Scope

      A "Live stats" feature opens a window and starts a timer; turning it off releases both together. Everything made through the child scope, and cleanups registered on it, go when the child is disposed; the parent scope is untouched.

      let live: Scope | null = null;
      plugin.commands.add({
      id: "live-stats",
      path: ["Tools", "Live stats"],
      checked: () => live !== null,
      run: async () => {
      if (live) {
      await live.dispose(); // closes the window, stops the timer
      live = null;
      return;
      }
      live = plugin.scope();
      const statsWindow = live.windows.create("ui/stats.slint");
      const timer = setInterval(() => live?.update(), 1000);
      live.onDispose(() => clearInterval(timer));
      await statsWindow.show();
      },
      });

      1.0.0

    • Adopt an existing handle: it is disposed together with this scope.

      Type Parameters

      Parameters

      • item: T

        Any Disposable, for example a handle created through another scope.

      Returns T

      item itself, for chaining.

      A filter made through the root scope is withdrawn when a child feature ends. add hands an existing disposable to this scope, which then disposes it with its own handles; it returns the same handle for chaining.

      const feature = plugin.scope();
      const blur = feature.add(plugin.video.filter("blur")); // now ends with `feature`
      blur.set([{ kind: "gblur", sigma: 4, steps: 3 }]);

      1.0.0

    • Run cleanup when this scope is disposed (for example clearInterval or closing a socket). It may be async; errors are logged.

      Parameters

      Returns Disposable

      A handle that cancels the registration early (without running cleanup).

      A once-a-second refresh runs as long as the plugin does. onDispose runs the cleanup when the scope is disposed, which for plugin is when the player stops the plugin, so the timer never outlives it.

      const timer = setInterval(() => plugin.update(), 1000); // re-evaluate bindings
      plugin.onDispose(() => clearInterval(timer));

      The plugin writes its cache file at once when the player crashed or was killed, instead of waiting for the next periodic save. The cleanup may get a DisposeInfo: stopping says the plugin itself stops (not a child scope), reason why.

      plugin.onDispose((info) => {
      // The player is gone: ask it nothing, keep what is local.
      if (info?.reason === "host-lost") saveCacheNow();
      });

      In the player (and in TestHost) the cleanup is called with one argument, a DisposeInfo: whether the plugin stops, and why. A cleanup that takes no argument works as well; a function with optional parameters of its own that is passed directly (onDispose(controller.abort.bind(controller))) now receives the DisposeInfo as its first argument: wrap it (() => controller.abort()) when that matters.

      1.0.0

    • Errors thrown by handlers that the SDK invoked (command run, window and panel callbacks, onChange listeners) in this scope. Without a listener they go to the parent scope, and finally to the plugin log.

      Rejections of async handlers count too, and so do failures of registrations made after activation (a command whose ready rejects, a property write the player refused).

      Parameters

      Returns Disposable

      When a menu command, a window callback or a listener of the plugin fails, the user sees why. The SDK catches what those handlers throw (and their rejected promises) and passes it here instead of only logging it; the message is data in a translated template.

      plugin.onError((error) => {
      void plugin.osd.show("Bookmarks: {}", [error.message]);
      });

      1.0.0

    • Re-evaluate every bound value (bind() functions and command state functions) and send what changed. The SDK already does this after each handler it invokes and when that handler's promise settles; call it after changing state from your own timers or between awaits of a long task.

      Several calls within one microtask are merged into one pass.

      Returns void

      A progress label moves while a long download runs, not only when it ends. The SDK re-evaluates bound values after each handler and when its promise settles; state changed between the awaits of a long handler shows only after an explicit update().

      let done = 0;
      downloadWindow.bind(() => ({ progress: done }));
      downloadWindow.on("start", async () => {
      for (let part = 0; part < 10; part++) {
      await downloadPart(part);
      done = part + 1;
      plugin.update(); // send `progress` now, not when the handler ends
      }
      });

      1.0.0

    • Plugin-owned state that bound values follow by themselves: reading a field in a bind function or a command's state function records it, and writing that field re-evaluates exactly those readers.

      Type Parameters

      • T extends object

      Parameters

      • initial: T

        The fields and their first values: a plain object.

      Returns T

      The tracked object.

      Returns an object of the same shape as initial (a copy of its own fields; initial itself is not tracked). A read inside a View.bind function or a CommandOptions field given as a function is recorded like a read of plugin.player.state; anywhere else (a handler, an onChange listener, a timer) it is a plain read, and writing there is how a handler updates what is bound. A write of a field (or a new field, or delete) schedules one update pass for the microtask turn, however many fields change, and that pass evaluates only the readers of what changed, not every binding and command as Scope.update does. Writing a value equal to the current one (Object.is) changes nothing.

      Tracking is one level deep: a field holding an object or array is compared by identity, so changing something inside it is not seen. Replace the object instead (st.list = [...st.list, item]). Do not write a field from a bind function that reads it: each write runs the function again; the SDK stops such a loop after 100 passes in a row and reports it to Scope.onError once (limit). The limit counts passes, not loops: a chain of bindings that is not a loop but deeper than 100 (each writing a field the next one reads) is cut the same way: what the dropped pass would have evaluated waits for the next full pass (after a handler, or Scope.update). Keep derived values in one function instead of chaining fields.

      The object is a Proxy: spread, Object.keys and JSON.stringify give its values; structuredClone does not take it (clone { ...st }). It belongs to this scope: once the scope is disposed it is a plain object, whose reads and writes still work but are no longer recorded and schedule no pass (as other handles of a disposed scope go quiet). update() stays for state the SDK cannot see.

      invalid (throws) initial is not a plain object (null, an array, a class instance).

      A panel shows whether the current file has video once an asynchronous check answers. The answer is written to a tracked field; only the bind function that reads it runs again and sends the new value, with no plugin.update() and no pass over every other binding.

      const st = plugin.state({ video: null as boolean | null });
      bar.bind(() => ({ keyframes: st.video === true })); // reads st.video
      plugin.player.on("source.ready", ({ state }) => {
      if (state.source === null) return;
      void hasVideo(state.source).then((video) => (st.video = video)); // re-runs the bind above
      });

      1.7.0

    • Makes a trigger: a condition the player keeps and evaluates, and the functions it calls when the condition becomes true and false, also waking the plugin from standby. Called only in the synchronous part of activate() (before its first await). Without a name the trigger is known by its place among the unnamed ones, and a condition it was given is cleared when the plugin is upgraded; with a name it is known by the name and survives an upgrade. At most 64 per plugin.

      Parameters

      • Optionalname: string

        Unique within the plugin, 1–64 characters.

      Returns Trigger

      Error without a code (throws) Called after the synchronous part of activate(), or on a scope made with plugin.scope() (a trigger is the plugin's: its condition outlives any scope).

      invalid (throws) A name used twice, or not 1–64 characters.

      limit (throws) A 65th trigger.

      A menu item pauses playback 45 minutes later. The trigger is named, so its condition stays with the player through standby and an update, and enter disarms it before pausing.

      const { when, player, commands } = plugin;
      const alarm = plugin.trigger("sleep").enter(async () => {
      alarm.off(); // fire once: the player forgets the condition
      await player.setPaused(true);
      });
      commands.add({
      id: "in45",
      path: ["Tools", "Sleep in 45 Minutes"],
      run: () => alarm.firesOn(when.time({ min: Date.now() + 45 * 60_000 })),
      });

      1.10.0

    commands: Commands

    Menu commands and their default bindings (commands).

    when: When

    Conditions on the player's own state for a command's enabled and checked: the player evaluates them, so the menu follows playback even while the plugin is stopped. See When.

    windows: Windows

    Tool windows from .slint files.

    panels: Panels

    Docked panels: bottom bar, sidebar and backdrop.

    dialogs: Dialogs

    Native file dialogs and confirmation alerts.

    player: Player

    Playback state and controls.

    video: {
        filter(id: string): VideoFilter;
        view(): VideoView;
        render(): RenderOptions;
        shaders(id?: string): VideoShaders;
        upscaling: VideoUpscaling;
        motion(engine: MotionEngine): VideoMotion;
    }

    Video processing: this plugin's filter chain, the display layer, the GPU render options, this plugin's shaders, the GPU's video upscaler and motion smoothing. The filter chain follows the player by itself while it exists (it applies when a video becomes ready).

    Type Declaration

    • filter: function
    • view: function
      • The display layer. The first plugin to call it owns the layer; another plugin's view fails with conflict until the owner disposes or stops.

        Returns VideoView

        Error without a code (throws) A second call in the same plugin while the first view is not disposed.

    • render: function
      • The GPU renderer's options, owned like the display layer. Under software rendering the handle is failed with unsupported after the player's first answer, and onError hears it.

        Returns RenderOptions

        Error without a code (throws) A second call in the same plugin while the first handle is not disposed.

    • shaders: function
      • This plugin's own GPU shaders named id (default "shaders"). Unlike render(), every plugin may hold shader handles at the same time; the player joins their lists. Nothing is sent until the first set().

        Parameters

        • Optionalid: string

          Local name of the handle, 1–128 bytes, unique within the plugin.

        Returns VideoShaders

        A VideoShaders owned by this scope.

        invalid (throws) id is empty, longer than 128 bytes or has control characters.

        Error without a code (throws) A second handle with the same id while the first is not disposed.

    • Readonlyupscaling: VideoUpscaling

      The GPU's video upscaler (NVIDIA RTX Video Super Resolution on Windows): whether it works here and why not, and turning it on or off for this plugin.

    • motion: function
      • Motion smoothing with one GPU vendor's frame-rate converter: whether it works here and why not, and this plugin's mode. amd is AMD AMF's on Windows; nvidia is NVIDIA's (FFmpeg's fruc_vulkan, GeForce RTX 30 and newer, on Windows; an older player reports engine for every mode).

        Parameters

        Returns VideoMotion

        A VideoMotion for that converter.

        invalid (throws) engine is not one of the two.

        0.8.1

        1.7.19

    audio: { filter(id: string): AudioFilter }

    Audio processing: this plugin's filter chain and delay (it follows the player as VideoFilter does).

    Type Declaration

    subtitles: Subtitles

    Subtitle tracks, uploads and style.

    Frozen snapshots and offline exports.

    resolvers: Resolvers

    Page-URL to stream-URL resolvers.

    packages: Packages

    The installed plugins; validation, installs.

    osd: Osd

    On-screen messages over the video.

    palette: Palette

    The command palette's lead row (palette.lead, built-in plugins only).

    host: Host

    The player's own core playback actions (commands).

    clipboard: Clipboard

    The system clipboard (clipboard).

    power: Power

    Keeping the computer awake while playing.

    tools: Tools

    ffmpeg / ffprobe, run by this plugin's process.

    storage: Storage

    JSON settings files in dataDirectory.

    system: System

    Show files in the file manager, open files and links.

    secrets: Secrets

    Small secrets in the system's secret store (secrets).

    mpv: Mpv

    mpv's own commands and properties, sent as they are (mpv).

    1.8.0

    window: MainWindow

    The main window: fullscreen, video area, size, level, pointer hiding.

    app: App

    The player's version and components, and the system it runs on.

    rendering: Rendering

    GPU or software rendering: read the choice, change it.

    bindings: Bindings

    Every command's bindings and the user's overrides.

    ui: Ui

    Runtime images for Slint image properties.

    timeline: Timeline

    Marks on the seek bar, merged from every plugin's layer.

    drops: Drops

    Files dropped on the video area, by extension.

    appearance: Appearance

    The player's palette and the saved interface language.

    i18n: I18n

    The interface language of this run (read-only).

    settings: Settings

    Pages in the player's options window.

    wire: Wire

    Direct messages to the player: requests by method name, raw events, direct property writes, bare command registrations. Experimental: the wire protocol is not semver; this member changes with versions. See Wire.

    1.7.0

    id: string

    The manifest id, e.g. "community.bookmark".

    dataDirectory: string

    A writable directory for this plugin's own files (settings, caches, remembered folders), created by the player before it starts the plugin. Each installation has its own directory: it is kept across restarts, disabling and upgrades, and a reinstall of the same id from a different source gets a new, empty one. It is deleted only by packages.uninstall(id, { removeData: true }).

    The path's format is not part of the API: do not derive another plugin's directory from it (a plugin manager reads PluginInfo.dataDirectory). Write files atomically (to a temporary name, then rename); for JSON settings prefer Scope.storage. Throws unavailable when the player provided none. See Store a plugin's data.

    stopReason: StopReason | undefined

    Why the player stops this plugin: set when the stop begins, before any Scope.onDispose cleanup runs. See StopReason.