"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.
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");
Keeping the computer awake.
Remarks
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.
Example: Keep the display on while playing
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.
Since
1.0.0