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

    Interface Panels

    Put a panel into the player's main window: the bottom bar, the sidebar or the backdrop. plugin.panels.

    A panel is part of the player's layout: it resizes with the main window, follows fullscreen and auto-hides with the player's own controls. Use one for content that should stay with the video (a playlist, chapters, a custom control bar, cover art); use a tool window for a tool the user opens and closes.

    A panel file exports one component and one global. The global is the bridge: the plugin writes its properties and handles its callbacks. The component lays the panel out and reads and calls the global. The split exists because the player places the component in its own windows: a new instance of the component is made whenever the panel's place is made again (a column closed and opened, its fullscreen overlay, the sidebar moving to or from its floating window; see Panel), while the global is one stable address.

    A plugin mounts at most one panel per slot: a playback plugin can have its control bar in "bottom" and its controls in "adjust". Each Panel has its own bridge, state, toggle() and setInteraction(); disposing one leaves the others, and stopping the plugin unmounts them all. The bottom bar and the backdrop hold one panel for all plugins; the sidebar and the adjust column one tab per plugin. The bottom bar is the player's control bar, a panel of the built-in vestra.playback: another plugin's mount there is refused, so do not plan on it; use "adjust", "sidebar" or a window. Panels.bottom, Panels.sidebar and Panels.adjust describe the positions, whoever mounted there.

    The sidebar gets an "Example list" tab showing three rows. mount returns at once; the SDK sends the mount with the values bound so far, and the player adds the panel as a tab. The Slint file exports the component and the bridge global whose properties bind writes.

    const panel = plugin.panels.mount("sidebar", "ui/panel.slint", {
    title: "Example list",
    });
    // Sent when the panel mounts, then whenever a value changes.
    panel.bind(() => ({ rows: items, selected }));

    ui/panel.slint:

    import { ListView } from "std-widgets.slint";
    import { Theme } from "@vestra/theme.slint";
    
    export global ListBridge {
        in property <[string]> rows;
        in property <int> selected;
        callback select(int);
        callback context-menu(float, float);
    }
    
    export component ListPanel inherits Rectangle {
        background: Theme.bg-list;
        min-width: 200px;
        // A ListView builds only the rows in view and scrolls the rest, so the
        // list costs the same with three rows or thirty thousand.
        ListView {
            for row[index] in ListBridge.rows: Rectangle {
                height: 20px;
                background: index == ListBridge.selected ? Theme.selected-bg : transparent;
                Text {
                    x: 6px;
                    text: (index + 1) + ". " + row;
                    color: index == ListBridge.selected ? Theme.text : Theme.text-list;
                    font-size: Theme.font-body;
                    vertical-alignment: center;
                }
                TouchArea {
                    pointer-event(event) => {
                        if event.kind == PointerEventKind.down {
                            ListBridge.select(index);
                        }
                        if event.kind == PointerEventKind.up && event.button == PointerEventButton.right {
                            ListBridge.context-menu((self.absolute-position.x + self.mouse-x) / 1px,
                                (self.absolute-position.y + self.mouse-y) / 1px);
                        }
                    }
                }
            }
        }
    }
    

    1.0.0

    interface Panels {
        mount(
            slot: "bottom" | "sidebar" | "adjust" | "backdrop",
            file: string,
            options?: { component?: string; global?: string; title?: string },
        ): Panel;
        backdrop: BackdropSlot;
        bottom: PanelSlot;
        sidebar: SidebarSlot;
        adjust: PanelSlot;
    }
    Index
    • Mount a Slint component in the bottom bar, the sidebar or the backdrop.

      Parameters

      • slot: "bottom" | "sidebar" | "adjust" | "backdrop"

        Where to mount the panel.

      • file: string

        Path relative to the package directory, for example "ui/playlist.slint".

      • Optionaloptions: { component?: string; global?: string; title?: string }

        component and global: the names to mount, needed only if the file exports more than one of either. title: the floating sidebar window's title (at most 128 bytes; default "Vestra Player"); not used for the other slots.

        • Optionalcomponent?: string

          The exported component to mount, if the file exports several.

        • Optionalglobal?: string

          The exported global to use as the bridge, if the file exports several.

        • Optionaltitle?: string

          The tab label and the floating sidebar window's title (at most 128 bytes).

      Returns Panel

      A Panel owned by this scope; await Panel.ready for the result.

      Returns at once; the panel is on screen when Panel.ready resolves. Handlers and bindings made right after mount() (in the same synchronous code) are part of the first values.

      • "bottom": held by the player's control bar (the built-in vestra.playback), so another plugin's mount there rejects ready with conflict and shows nothing (the plugin keeps running, with the warning slot-occupied); a plugin does not plan on it. The bar itself sits under the video, as wide as the video column, as tall as the component's preferred height. It may draw above its slot into the video area (negative y); the player does not clip it. In fullscreen it floats over the video and shows only while the pointer is in its band at the bottom of the screen (hidden 500 ms after the pointer leaves; Panel.setInteraction locks keep it).
      • "sidebar": right of the video, the window's full height, as wide as the user drags it (at least 317). The user can detach it into a floating window titled title. Several plugins may mount here: each panel is a tab, labelled title (else the plugin's name), and the player draws a 31px tab strip above the current one while there are two or more (with one panel, nothing changes). Showing, hiding and detaching apply to the whole sidebar. If the bridge global declares in property <bool> tabbed, the player sets it to true while it draws the strip, so a panel with a tab strip of its own can hide it. Panel coordinates (drops) start below the strip.
      • "backdrop": the whole video area, under the OSD, while there is no video picture (see Panels.backdrop). One plugin at a time (as for the bottom bar, another one's mount rejects with conflict); it takes no pointer or keyboard input. While it is mounted, the player does not show the cover art of audio files itself (from the next file opened on), so the plugin can draw it.
      • "adjust": controls that change what is playing: the picture, the sound, the subtitles, the speed (the player's own Picture, Audio, Subtitles and Playback panels, a colour grading tool). Several plugins may mount here, one tab each, labelled title (else the plugin's name).

      Choosing between "sidebar" and "adjust". The slot says what the panel is for; the player decides how it looks and may change that at any time. Ask: after the user closes the panel, do they still look at what it showed? If yes (a list, chapters, search results, another video), it is content: "sidebar". If it only changes what is playing, it is "adjust".

      What the player shows today (may change; do not depend on it). The adjust column is a second column between the video and the sidebar ([video][adjust][sidebar]; both can be open, the sidebar always rightmost), 317 wide by default, 280 to half the window, with text tabs and the key that opens each tab under its title (the key of the command your other commands name as their home). It has no close or detach button: Adjustments and Effects (host/adjust, a menu item and the bottom bar's sliders button), your panel's own command (Panel.toggle) and the menus open and close it. It starts closed. In a window too narrow to dock it beside a video at least 480 wide, it floats over the right of the video, 300 wide; in fullscreen it slides out from the right edge, left of the sidebar. Its width, open state, current tab and tab order are remembered across launches. Its strip is always drawn, so panel coordinates (drops) start below it, and the bridge global's tabbed property, if declared, is true. As in the sidebar, only the current tab's plugin is kept running while the column is open. The player compiles an adjust panel when the column opens (its first tabs, up to 4) or when the tab is first shown, not at the mount while the column is closed (see Panel.ready).

      Error without a code (throws) This plugin already has a panel in this slot (a panel in another slot is fine), or the file exports no component or global, or several and options does not name one. A file that cannot be read throws Node's file system error (code ENOENT and so on).

      The errors of Panel.ready (rejects ready) The player refused the mount.

      The plugin's own control bar appears under the video, its slider following the playback position and seeking when dragged. Bindings and handlers made right after mount are part of the first values; ready resolves once the main window shows the bar, and rejects with conflict when another plugin's panel holds the bottom bar. This is the built-in vestra.playback's case: on a player with its control bar, any other plugin gets conflict here.

      const bar = plugin.panels.mount("bottom", "ui/bar.slint");
      // Sent again whenever the position changes, while a stream is open.
      bar.bind(() => ({ position: plugin.player.state.position ?? 0 }));
      bar.on("seek", (seconds: number) => plugin.player.seek(seconds));
      await bar.ready;
      // The bar shows the position (and keeps the plugin running anyway):
      // a stream makes `plugin.player.state` follow the player.
      plugin.player.stream(() => {});

      1.0.0

    backdrop: BackdropSlot

    The backdrop position: whether a backdrop is mounted (by any plugin) and shown now.

    bottom: PanelSlot

    The bottom bar position, whoever mounted it; any plugin may read and toggle it.

    sidebar: SidebarSlot

    The sidebar position, including its floating state; any plugin may read and toggle it.

    adjust: PanelSlot

    The adjust column, whoever mounted there; any plugin may read and toggle it. The same shape as Panels.sidebar without floating: the adjust column never detaches.

    state is null while no plugin has a panel there. The column starts hidden (preferred: false, reason: "userHidden") until the user opens it. To open the column at your own panel, call Panel.show (or Panel.toggle, which closes it again when your tab is already the current one, the behaviour of the player's own Alt+1…4).

    One command opens the column at the plugin's tab, and pressing it again while that tab is shown closes the column. The panel's other commands name it as their home, so the player shows its key under the tab and the command palette knows where they live.

    const panel = plugin.panels.mount("adjust", "ui/wheels.slint", { title: "Wheels" });
    plugin.commands.add({
    id: "wheels",
    title: "Colour Wheels",
    bindings: ["Alt+5"],
    // Opens the column at this tab; closes it when this tab is shown.
    run: () => panel.toggle(),
    });
    plugin.commands.add({
    id: "wheels-reset",
    title: "Reset Colour Wheels",
    // Lives in the panel `wheels` opens: its key shows under the tab.
    home: "wheels",
    run: () => panel.set({ lift: 0 }),
    });

    0.7.6

    1.6.11