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

    Interface SidebarSlot

    The sidebar position: a PanelSlot that can also float in a window of its own.

    Detached, the sidebar panel is shown in a separate window (300×408 by default, at least 300×250) with the panel's title. The plugin's properties and callbacks stay the same, but the window holds a new instance of the component. Closing the floating window (its close button or the standard close keys) is the same as setVisible(false).

    Tools ▸ Detach sidebar floats the sidebar in its own window and docks it again, with a check mark while it floats. setDetached moves all the sidebar's tabs; the floating window holds new instances of the panels, which keep the plugins' properties and callbacks.

    const sidebar = plugin.panels.sidebar;
    plugin.commands.add({
    id: "detach",
    path: ["Tools", "Detach sidebar"],
    // Detaching moves every tab of the sidebar into the floating window.
    checked: () => sidebar.state?.detached ?? false,
    enabled: () => sidebar.state !== null,
    run: () => sidebar.setDetached(!sidebar.state?.detached),
    });

    1.0.0

    interface SidebarSlot {
        state: SlotState | null;
        panels: readonly SlotPanel[] | null;
        onChange(listener: (state: SlotState | null) => void): Disposable;
        setVisible(visible: boolean): Promise<void>;
        toggle(): Promise<void>;
        activate(plugin: string): Promise<void>;
        setDetached(detached: boolean): Promise<void>;
    }

    Hierarchy (View Summary)

    Index
    • Run code when the position's state changes.

      Parameters

      • listener: (state: SlotState | null) => void

        Receives the new state.

      Returns Disposable

      A handle that removes the listener.

      The listener runs on every change, whoever caused it (it keeps the plugin running while it exists; layout.changed with Player.on does not). Called with null when the panel there is unmounted, and also when only the tabs changed (PanelSlot.panels: a panel added or removed, another tab current). Errors go to Scope.onError.

      When the sidebar should show but the window has no room for it, the OSD says so. The listener runs on every change of the position, whoever caused it. The player reports reason: "space" when the preference is to show the sidebar but the window is too small.

      plugin.panels.sidebar.onChange((state) => {
      // `null`: no panel is mounted in the sidebar any more.
      if (state?.reason === "space") void plugin.osd.show("Widen the window to see the playlist");
      });

      1.0.0

    • Show or hide the panel at this position: set the user's preference.

      Parameters

      • visible: boolean

        The new preference.

      Returns Promise<void>

      Resolves once the layout has the new preference, with state refreshed.

      The same as the user's menu item: the preference is remembered. Showing may still leave the panel off screen (reason: "space"); in fullscreen, true pops the sidebar overlay out at once.

      missing (rejects) No panel is mounted at this position.

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

      The control bar disappears, as if the user had hidden it from the menu, and stays hidden at the next start because the preference is remembered. setVisible rejects with missing when no panel is in the bottom bar, which this plugin treats as nothing to hide.

      await plugin.panels.bottom.setVisible(false).catch((error: PluginError) => {
      if (error.code !== "missing") throw error; // no bar mounted: nothing to do
      });

      1.0.0

    • Flip the user's preference, using the player's current value.

      Returns Promise<void>

      Resolves once the layout has the new preference.

      Reads the state from the player first, so it is right even when the copy does not follow the player. It is a switch, the same in every mode: in fullscreen a column switched on is revealed by the pointer at the right edge, and is not popped out by the toggle (setVisible(true) pops it out). Switching it off while it is out slides it in at once.

      missing (rejects) No panel is mounted at this position.

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

      Screen ▸ Control bar shows or hides the bottom bar and carries a check mark while it is shown. toggle reads the player's current preference first, so it is right even when nothing follows the layout; checked is evaluated again after the command runs and follows state.

      plugin.commands.add({
      id: "toggle-bar",
      path: ["@screen", "Control bar"],
      // The user's preference, remembered across launches.
      checked: () => plugin.panels.bottom.state?.preferred ?? false,
      run: () => plugin.panels.bottom.toggle(),
      });

      1.0.0

    • Make a panel's tab the current one, without showing or hiding the position.

      Parameters

      • plugin: string

        The manifest id of the plugin whose panel to show, one of PanelSlot.panels.

      Returns Promise<void>

      Resolves once the layout has the new current tab, with state refreshed.

      The sidebar holds the panels of several plugins as tabs (see Panels.mount); this switches which one it shows, like a click on its tab. To show this plugin's own panel, use Panel.show. The bottom bar has one panel: activating it changes nothing.

      missing (rejects) No panel is mounted at this position, or none of plugin.

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

      A command makes the playlist the sidebar's current tab without showing or hiding the sidebar, like a click on its tab. activate takes the manifest id of the plugin whose tab to show and rejects with missing when that plugin has no panel there.

      plugin.commands.add({
      id: "to-playlist",
      title: "Show the playlist tab",
      run: () => plugin.panels.sidebar.activate("vestra.playlist"),
      });

      1.5.2

    • Float the sidebar panel in its own window, or attach it back.

      Parameters

      • detached: boolean

        true to float, false to dock.

      Returns Promise<void>

      Resolves once the layout has changed, with state refreshed.

      missing (rejects) No panel is mounted in the sidebar.

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

      The sidebar moves into its own window, or back into the main window when it already floats. state says whether it is detached now; setDetached resolves once the layout changed, with state refreshed.

      const sidebar = plugin.panels.sidebar;
      await sidebar.setDetached(!sidebar.state?.detached);

      1.0.0

    state: SlotState | null

    The current state; null while no plugin has a panel there. With sidebar tabs it is the whole position's: shown, hidden and floating apply to all tabs, which PanelSlot.panels lists.

    panels: readonly SlotPanel[] | null

    The position's panels in tab order: the sidebar's tabs, the bottom bar's one panel; null while there is none (as state). Refreshed with state.

    Never.

    1.5.2