summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-client
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-10-04 22:46:00 +0200
committerChristophe Besson <cbesson@gmail.com>2026-10-04 22:46:00 +0200
commit652465910dcdcc761aa2e078ff1a82625e2a0aa5 (patch)
tree2378741f73ef0faaf138689ea366febef905e85c /packages/meshbay-client
parent859d7ce71795dcfd5701cb08a684dcef23e7c4c0 (diff)
downloadmeshbay-652465910dcdcc761aa2e078ff1a82625e2a0aa5.tar.gz
feat(android): music keeps playing with the screen off
While a track plays, the page asks the shell to stay awake (playback:keep-alive): on Android the cast's foreground service and visible WebView, with a notification; on desktop a power save blocker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-client')
-rw-r--r--packages/meshbay-client/src/main.js17
-rw-r--r--packages/meshbay-client/src/preload.js5
2 files changed, 20 insertions, 2 deletions
diff --git a/packages/meshbay-client/src/main.js b/packages/meshbay-client/src/main.js
index 4c8707c..fa4f3ec 100644
--- a/packages/meshbay-client/src/main.js
+++ b/packages/meshbay-client/src/main.js
@@ -20,8 +20,8 @@
'use strict';
-const { app, BrowserWindow, dialog, ipcMain, Menu, protocol, safeStorage,
- shell, Tray } =
+const { app, BrowserWindow, dialog, ipcMain, Menu, powerSaveBlocker, protocol,
+ safeStorage, shell, Tray } =
require('electron');
const { execFile, spawn } = require('node:child_process');
const crypto = require('node:crypto');
@@ -2304,6 +2304,19 @@ function registerBridge() {
return true;
});
+ // The screen may sleep while music plays; the machine may not, or the
+ // connection to the node goes with it.
+ let playbackBlocker = null;
+ handle('playback:keep-alive', async (_event, on) => {
+ if (on === true && playbackBlocker === null) {
+ playbackBlocker = powerSaveBlocker.start('prevent-app-suspension');
+ } else if (on !== true && playbackBlocker !== null) {
+ powerSaveBlocker.stop(playbackBlocker);
+ playbackBlocker = null;
+ }
+ return true;
+ });
+
handle('cast:status', async () => ({
active: castRelay.active,
url: castRelay.url,
diff --git a/packages/meshbay-client/src/preload.js b/packages/meshbay-client/src/preload.js
index 43cf317..3af6c10 100644
--- a/packages/meshbay-client/src/preload.js
+++ b/packages/meshbay-client/src/preload.js
@@ -165,6 +165,11 @@ contextBridge.exposeInMainWorld('meshbay', {
serviceMode: (action) => ipcRenderer.invoke('node:service-mode', action),
},
+ // Music is playing: the machine must not idle-sleep under it.
+ playback: {
+ keepAlive: (on) => ipcRenderer.invoke('playback:keep-alive', on === true),
+ },
+
// LAN cast relay. The main process runs a local HTTP server and the
// renderer feeds it decrypted segments. A Chromecast or Smart TV on the
// same Wi-Fi plays from the URL.