Skip to content

Commit

Permalink
Request WakeLock when enabling the screensaver
Browse files Browse the repository at this point in the history
  • Loading branch information
dinoosauro committed Jul 21, 2024
1 parent b0a1ea4 commit 0052525
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@
});
});
let showSettings = false;
let wakeLock: WakeLockSentinel | undefined;
showScreensaver.subscribe((val) => {
for (const item of document.querySelectorAll("video"))
item[val ? "pause" : "play"](); // Pause the previous videos if the screensaver is enabled
document.body.style.overflow = val ? "hidden" : "auto";
!val && FullscreenManager.remove();
val
? navigator.wakeLock.request().then((res) => (wakeLock = res))
: wakeLock?.release();
});
</script>

Expand Down

0 comments on commit 0052525

Please sign in to comment.