diff options
| author | Luke Hoersten <[email protected]> | 2026-06-15 08:45:37 -0500 |
|---|---|---|
| committer | Luke Hoersten <[email protected]> | 2026-06-15 08:45:37 -0500 |
| commit | c63c36e538068c23144aea74b36edbc1e4a1f9d5 (patch) | |
| tree | 5c416f433c055034cbe4740c97197d3c322d21bc | |
| parent | b9a2df3e6c7b1184c29e96b7e01c14acd3f7ea56 (diff) | |
scrypted: restart live stream when settings change
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.
| -rw-r--r-- | scrypted/scrypted-viewport.ts | 19 |
1 files changed, 16 insertions, 3 deletions
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)); }; |
