From c63c36e538068c23144aea74b36edbc1e4a1f9d5 Mon Sep 17 00:00:00 2001 From: Luke Hoersten Date: Mon, 15 Jun 2026 08:45:37 -0500 Subject: scrypted: restart live stream when settings change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit onBindingChanged previously stopped the active stream and waited for the next camera event to relaunch. Changing orientation, frame interval, or camera meant the user saw no immediate effect — the display sat dark until the next motion/doorbell trigger. Now if a stream was live at change-time we relaunch it right after registerViewport pushes the new /config. Guarded by streamStarting so the relaunch doesn't race with a concurrent camera-event-triggered start. --- scrypted/scrypted-viewport.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'scrypted') diff --git a/scrypted/scrypted-viewport.ts b/scrypted/scrypted-viewport.ts index 68386e2..3b83b08 100644 --- a/scrypted/scrypted-viewport.ts +++ b/scrypted/scrypted-viewport.ts @@ -426,11 +426,24 @@ class ScryptedViewportProvider extends ScryptedDeviceBase this.bindingDebounce.delete(nid); this.detachListener(nid); // Any active stream for this viewport is now stale (camera - // may have changed). Stop cleanly; next event/wake will - // start fresh. + // or orientation may have changed). Stop cleanly; if it + // was live we relaunch immediately under the new settings + // so the user sees the change without waiting for the next + // camera event. + const wasStreaming = this.streams.has(v.name); this.stopStream(v.name, /*sendSleep=*/ false); this.attachListener(v); - this.registerViewport(v).catch(() => {}); + this.registerViewport(v) + .then(() => { + if (wasStreaming) { + if (this.streamStarting.has(nid)) return; + this.streamStarting.add(nid); + this.startStream(v) + .catch(e => this.console.error("restart after setting change failed", e)) + .finally(() => this.streamStarting.delete(nid)); + } + }) + .catch(() => {}); }, 300)); }; -- cgit v1.2.3