Add full-image lightbox and restore WLED state on stop
- Add GET /picture-streams/full-image endpoint to serve full-res images - Click static image preview thumbnail to open full-res lightbox - Snapshot WLED state (on/off, lor, AudioReactive) before streaming - Restore saved WLED state when streaming stops Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -120,6 +120,8 @@ class ProcessorState:
|
||||
# Capture libraries (BetterCam, MSS, DXcam) use thread-local state,
|
||||
# so all calls must run on the same thread.
|
||||
capture_executor: Optional[concurrent.futures.ThreadPoolExecutor] = None
|
||||
# WLED state snapshot taken before streaming starts (to restore on stop)
|
||||
wled_state_before: Optional[dict] = None
|
||||
|
||||
|
||||
class ProcessorManager:
|
||||
@@ -401,6 +403,24 @@ class ProcessorManager:
|
||||
# Resolve stream settings
|
||||
self._resolve_stream_settings(state)
|
||||
|
||||
# Snapshot WLED state before streaming changes it
|
||||
try:
|
||||
async with httpx.AsyncClient(timeout=5) as http:
|
||||
resp = await http.get(f"{state.device_url}/json/state")
|
||||
resp.raise_for_status()
|
||||
wled_state = resp.json()
|
||||
state.wled_state_before = {
|
||||
"on": wled_state.get("on", True),
|
||||
"lor": wled_state.get("lor", 0),
|
||||
}
|
||||
# AudioReactive is optional (usermod)
|
||||
if "AudioReactive" in wled_state:
|
||||
state.wled_state_before["AudioReactive"] = wled_state["AudioReactive"]
|
||||
logger.info(f"Saved WLED state before streaming: {state.wled_state_before}")
|
||||
except Exception as e:
|
||||
logger.warning(f"Could not snapshot WLED state: {e}")
|
||||
state.wled_state_before = None
|
||||
|
||||
# Connect to WLED device
|
||||
try:
|
||||
use_ddp = state.led_count > 500
|
||||
@@ -488,6 +508,19 @@ class ProcessorManager:
|
||||
pass
|
||||
state.task = None
|
||||
|
||||
# Restore WLED state that was changed when streaming started
|
||||
if state.wled_state_before:
|
||||
try:
|
||||
async with httpx.AsyncClient(timeout=5) as http:
|
||||
await http.post(
|
||||
f"{state.device_url}/json/state",
|
||||
json=state.wled_state_before,
|
||||
)
|
||||
logger.info(f"Restored WLED state: {state.wled_state_before}")
|
||||
except Exception as e:
|
||||
logger.warning(f"Could not restore WLED state: {e}")
|
||||
state.wled_state_before = None
|
||||
|
||||
# Close WLED connection
|
||||
if state.wled_client:
|
||||
await state.wled_client.close()
|
||||
|
||||
Reference in New Issue
Block a user