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

    Interface Clipboard

    The system clipboard (clipboard). Unavailable without a user interface.

    Platforms: macOS writes text as UTF-8 and images as their original PNG/JPEG bytes; Windows writes Unicode text and images as a bitmap plus PNG. Other systems: unsupported. Failures: invalid, missing, unavailable, failed (the system refused).

    The clipboard holds "path @ seconds" for pasting into a note. The player writes the system clipboard; it rejects with unsupported on systems other than macOS and Windows and failed when the system refuses, which the plugin reports.

    const { source, position } = plugin.player.state;
    try {
    await plugin.clipboard.writeText(`${source} @ ${position}`); // data, not shown
    } catch (error) {
    void plugin.osd.show("Could not copy: {}", [(error as PluginError).code]);
    }

    The player reads and writes the system clipboard on the plugin's behalf. Text is plain text; images are written from a PNG or JPEG file.

    1.0.0

    interface Clipboard {
        readText(): Promise<string | null>;
        writeText(text: string): Promise<void>;
        writeImage(path: string): Promise<void>;
    }
    Index
    • Plain text on the clipboard; null when it holds none.

      Returns Promise<string | null>

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

      unsupported (rejects) A system other than macOS and Windows.

      failed (rejects) The system refused (Windows).

      A "Paste and play" command opens the address on the clipboard. readText resolves with the clipboard's text, or null when it holds none (an image, nothing).

      const text = await plugin.clipboard.readText();
      if (text?.startsWith("https://")) await plugin.player.open(text.trim());

      1.0.0

    • Replace the clipboard with text (at most 1 MiB of UTF-8).

      Parameters

      • text: string

      Returns Promise<void>

      invalid (rejects) More than 1 MiB of UTF-8.

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

      unsupported (rejects) A system other than macOS and Windows.

      failed (rejects) The system refused.

      The path of the playing file is put on the clipboard, replacing what was there. It resolves once the system has it.

      const { source } = plugin.player.state;
      if (source) await plugin.clipboard.writeText(source);

      1.0.0

    • Replace the clipboard with a PNG or JPEG file (absolute path, at most 16 MB).

      Parameters

      • path: string

      Returns Promise<void>

      missing (rejects) The file does not exist.

      invalid (rejects) Not an absolute path, not PNG or JPEG, over 16 MB, or (Windows) an image the system cannot decode.

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

      unsupported (rejects) A system other than macOS and Windows.

      failed (rejects) The system refused.

      A frame the plugin saved as PNG is put on the clipboard, ready to paste into another application. The player reads the file and writes the image (macOS: its original bytes; Windows: a bitmap plus PNG).

      await plugin.clipboard.writeImage(pngPath); // absolute path, at most 16 MB
      await plugin.osd.show("Snapshot copied");

      1.0.0