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

    Interface Osd

    Text the player draws over the video: short messages and an information block. plugin.osd.

    The on-screen display (OSD) is the lightest way to tell the user something: no Slint file, no window, visible in fullscreen. A message (Osd.show) is one line at the top left of the video that disappears after 2 seconds; a newer message, from any plugin, replaces it. The information block (Osd.panel) stays until the plugin changes or removes it.

    How the player draws them (a player before 0.4.0 drew bold white text with a black outline instead):

    • Message: white text on a translucent dark plate with rounded corners and a gradient line along its bottom edge, 10px from the video area's left and top edges.
    • Font size follows the video area: 3 % of its height, rounded and clamped to 12–48px (about 18px in the default window, 32px in fullscreen at 1080 pixels high). The plate's padding and corners scale with it.
    • Information block: 4px below the message plate, on the same kind of plate; its font scales in proportion (11px when the message is 16px), clamped to 9–28px.

    How long a text may be is in Limits: on-screen display (OSD_LIMITS).

    "Blur on" appears over the video unless the user turned messages off in the plugin's settings. osd.show asks the player to draw the text for a moment; the plugin checks its own stored preference before each call.

    const store = plugin.storage.json("prefs", { defaults: { messages: true } });
    const say = (text: string) => {
    if (store.value.messages) void plugin.osd.show(text);
    };
    say("Blur on");

    1.0.0

    interface Osd {
        show(
            text: TextValue,
            args?: TemplateArgs | null,
            options?: OsdShowOptions,
        ): Promise<void>;
        panel(): OsdPanel;
    }
    Index
    • Show a one-line message at the top left of the video for 2 seconds.

      Parameters

      • text: TextValue

        The template, 1–200 characters once translated and formatted; line breaks become spaces. With options.actions the message ends in up to two buttons, each running one of the plugin's own commands (OsdShowOptions).

      • Optionalargs: TemplateArgs | null

        Values for its placeholders. Pass null with a Text and options.

      • Optionaloptions: OsdShowOptions

        Action buttons after the text.

      Returns Promise<void>

      Resolves once the message is on screen.

      Replaces the message on screen, whichever plugin showed it. A message that is on screen when the plugin stops still disappears on time.

      The text is a template in English: the player shows its translation from the plugin's catalog, with the placeholders ({}, {0}, {name}; {{ and }} for braces) filled from args. Without args the text shows as it is (braces included). Untranslated, the English template is formatted. Never compose the sentence in TypeScript (`Speed ${rate}×`): translators can only translate whole templates. An argument that is itself words is a Text, and a message made of a varying number of parts is a TextList of texts; text may also be a Text (then without args).

      invalid (rejects) The shown text is empty, only white space, or longer than 200 characters, or args is not a TemplateArgs; or there are more than 2 actions, a title is empty or longer than 40 characters once translated, or a command is not one of the plugin's.

      unavailable (rejects) The player runs without a user interface.

      The OSD shows "Bookmark added", then "Speed 1.5×" in the user's language. The text is English source the player translates with the plugin's catalog; {} is filled in with the argument, which stays as it is because it is data.

      await plugin.osd.show("Bookmark added");
      await plugin.osd.show("Speed {}×", [plugin.player.state.rate]);

      The OSD reads "Saved clip.mp4 [Show in Folder]" for about 4 seconds, longer while the pointer is on it. A click runs the plugin's own reveal command, which knows the last saved file; the message goes.

      let saved = path; // the command acts on the last saved file
      plugin.commands.add({
      id: "reveal",
      title: "Show Last Saved File in Folder",
      enabled: () => saved !== "",
      run: () => plugin.system.reveal(saved),
      });
      await plugin.osd.show("Saved {}", [saved.split(/[\\/]/).pop() ?? saved], {
      actions: [{ title: "Show in Folder", command: "reveal" }], // one button
      });

      1.0.0

    • Create this plugin's information block.

      Returns OsdPanel

      An OsdPanel owned by this scope.

      Nothing is shown until OsdPanel.set. A plugin has one block; dispose it before creating another.

      Error without a code (throws) This plugin already has a block.

      A small block over the video says "Loop: off" until the plugin changes or hides it. Each plugin has one block, stacked with other plugins' blocks; a second panel() call throws.

      const info = plugin.osd.panel();
      info.set("Loop: off");

      1.0.0