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

    Interface PanelSlot

    The bottom bar, the sidebar or the adjust column position (plugin.panels.bottom, plugin.panels.sidebar, plugin.panels.adjust), independent of who mounted the panel there.

    The position does not belong to the plugin that mounted the panel: any plugin may read and toggle it, so a "Show playlist" command can live in a different plugin than the playlist. The player remembers the sidebar's visibility, width, detached state and floating window position across launches.

    state is read when first used. While an onChange listener exists it follows every change (the user, other plugins, the window size), and it takes each layout.changed a Player.on listener hears; otherwise it refreshes only after this plugin's own changes.

    Tools ▸ Show sidebar shows or hides the sidebar, whichever plugin's panel is in it, with a check mark while it is shown. The position does not belong to the plugin that mounted the panel: state is null while nobody has a panel there (the item is disabled then), and toggle flips the user's remembered preference.

    const sidebar = plugin.panels.sidebar;
    plugin.commands.add({
    id: "sidebar",
    path: ["Tools", "Show sidebar"],
    // `state` is null while no plugin has a panel in the sidebar.
    checked: () => sidebar.state?.preferred ?? false,
    enabled: () => sidebar.state !== null,
    run: () => sidebar.toggle(),
    });

    1.0.0

    interface PanelSlot {
        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>;
    }

    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

    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