Skip to content

feat(videoWindow): add VideoWindow component for video on Crestron panels - #111

Merged
ndorin merged 2 commits into
mainfrom
feat/video-window
Nov 19, 2026
Merged

ndorin merged 2 commits into
mainfrom
feat/video-window

Conversation

@andrew-welker

Copy link
Copy Markdown
Contributor

Summary

Adds VideoWindow, a single React component that shows a video stream on a Crestron touch panel (TSW, TS) or DGE. It does the job that ch5-video and ch5-background do together in Crestron's CH5 component library.

<VideoWindow
  url="rtsp://192.168.1.50/stream1"   // not needed for HDMI
  sourceType="Network"                // 'Network' | 'HDMI' | 'DM'
  userId="admin"
  password="…"
  play={showCamera}
  style={{ width: 640, height: 360 }}
  onStatusChange={(status, code, message) => console.log(status, message)}
>
  <CameraControls />                  {/* drawn on top of the video */}
</VideoWindow>

What changed and why

The browser on a panel does not decode video. The panel firmware decodes it and draws it on a layer underneath the web page, so the page has to be see-through where the video sits.

  • VideoWindow.tsx sends the same Csig.video.request start, resize and stop messages as ch5-video and reads Csig.video.response for status. It only runs the video while the window is at least 98% on screen (the CH5 threshold), re-sends the location when the element moves or resizes, and stops the video on unmount and on pagehide.
  • videoBackdrop.ts replaces ch5-background. While a video is running it copies the <html>/<body> background onto a fixed layer behind the page, makes <html> and <body> transparent, and clips a hole in that layer over each video. Everything is restored when the last video stops.
  • videoTransport.ts covers the app being loaded in an iframe by the touch panel wrapper app. In that case requests and responses go through the parent page with postMessage, because the panel only talks to the top-level page and only the parent knows where the iframe is on screen. Loaded directly on the panel, the component talks to CrComLib as before. The other half is in PepperDash/mobile-control-touchpanel-wrapper-app (branch feat/video-relay).
  • Off a Crestron panel, or in an iframe whose parent has no relay, the status is unsupported and a black box is shown.

Left out compared with ch5-video: snapshot images, the fullscreen button, multi-source selection by join, and the send-event joins.

Testing

  • npm run lint and npm run build pass.
  • Browser test with a simulated panel bridge (Playwright, JSInterface stubbed), both loaded directly and inside the built wrapper app's iframe: start request has the right location, a simulated started response opens the hole and restores it on error, a background colour set inline on <body> survives a start/stop cycle, pagehide sends a stop.
  • Not tested on a real TSW or DGE. That is the main thing still to do before relying on this.

Notes for reviewers

  • Any element between <body> and the component with its own solid background will cover the video. alphaBlend={false} asks the panel to draw the video over the page instead, which hides children.
  • The four relay message names are duplicated in the wrapper app. It cannot import this library without loading a second copy of CrComLib, which would break its join handling.
  • When the parent page's origin is "null" (a page loaded from a file), requests, including the stream user name and password, are posted with a wildcard target because "null" cannot be used as one. They still only go to window.parent. Worth confirming what origin the wrapper has on a real panel.
  • Pre-PR review changed three things: the app now stops its video on pagehide and restarts it if the wrapper resets it (a reload could leave a video running); backgrounds are made transparent with an attribute and a style rule instead of inline styles (an inline background-color was being wiped on restore); two comments were corrected.
  • Declined from that review: ignoring late responses from a previous stream with the same id (CH5 behaves the same way, and the status corrects itself on the next response); guarding against a zero-size window and against overlapping windows (both are usage errors, and the component documents that it needs a size).

🤖 Generated with Claude Code

https://claude.ai/code/session_018uDiZZz3jRd9CFVoYcPSJb

…nels

Adds a single React component that shows a video stream on a TSW/TS panel
or DGE, covering what ch5-video and ch5-background do in CH5: it sends the
start/resize/stop requests to the panel and makes the page background
see-through where the video is drawn.

When the app is loaded in an iframe, requests and responses go through the
parent page with postMessage (the touch panel wrapper app relays them).

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018uDiZZz3jRd9CFVoYcPSJb
Copilot AI balanced review requested due to automatic review settings November 19, 2026 21:55
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.26.0-feat-video-window.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved issues can leave video windows misaligned after layout shifts, playback stopped after back/forward-cache restoration, and page backgrounds altered when root and body backgrounds require compositing.

3 open issues
What changed in this PR

Adds VideoWindow to the core React library for displaying firmware-decoded video on Crestron touch panels and DGEs, combining video control and transparent-background handling in one component.

Changes:

  • Adds Network, HDMI, and DM sources with playback controls and status callbacks.
  • Supports direct CrComLib communication and iframe communication through a parent-page relay.
  • Introduces visibility-based playback, location updates, and background cutouts.
File Description
src/​lib/​shared/​VideoWindow/​VideoWindow.tsx Adds the component, playback lifecycle, positioning, and status handling.
src/​lib/​shared/​VideoWindow/​VideoWindow.module.scss Defines black fallback and transparent playback backgrounds.
src/​lib/​shared/​VideoWindow/​videoTransport.ts Handles direct panel communication and iframe relay messaging.
src/​lib/​shared/​VideoWindow/​videoStatusMessages.ts Maps panel status codes to readable messages.
src/​lib/​shared/​VideoWindow/​videoBackdrop.ts Manages page backgrounds and clips video cutouts.
src/​lib/​shared/​VideoWindow/​index.ts Exports the component, types, and status messages.
src/​lib/​shared/​index.ts Exposes VideoWindow through the shared library exports.

Review effort: Balanced

- restart the video when the page is restored from the back/forward cache
- check the position of a running video every 250 ms, so a layout shift
  with no resize or scroll event still moves the video and the hole
- copy both the html and body backgrounds onto the backdrop as two layers
- tell the parent page which colour scheme the app uses, so the wrapper
  can match it on the iframe

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018uDiZZz3jRd9CFVoYcPSJb
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.26.0-feat-video-window.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ndorin
ndorin merged commit 693978a into main Nov 19, 2026
3 checks passed
@ndorin
ndorin deleted the feat/video-window branch November 19, 2026 22:06
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.26.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants