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

    Interface Power

    Keeping the computer awake.

    A request, not a command: the player keeps the system awake while any plugin asks for it and a source plays, and withdraws a plugin's request when it stops.

    The screen does not dim or sleep while a video plays, and may again when it is paused or ends. The player takes the system's assertion only while a source is ready and not paused.

    await plugin.power.preventSleep("playing"); // "off" withdraws the request
    

    1.0.0

    interface Power {
        preventSleep(mode: "off" | "playing"): Promise<void>;
    }
    Index
    • "playing": while a source is ready and not paused, keep the display (video) or the system (audio only) from sleeping. Any plugin asking is enough; a stopped plugin's request is withdrawn.

      It only registers the request (invalid for a bad mode); failures to take the system assertion are logged by the player, not reported. macOS uses caffeinate, Windows the thread execution state; elsewhere it has no effect.

      Parameters

      • mode: "off" | "playing"

      Returns Promise<void>

      invalid (rejects) A mode other than "off" or "playing".

      The plugin keeps the display awake during playback only while its setting is on. Each call replaces this plugin's request; "off" withdraws it, and other plugins' requests still count.

      const store = plugin.storage.json("power", { defaults: { keepAwake: true } });
      await plugin.power.preventSleep(store.value.keepAwake ? "playing" : "off");

      1.0.0