import { runtime, devTools } from '../../../build/module'; (window as any).devTools = devTools; const app = document.querySelector('#app'); if (!app) throw new Error('Missing app element'); // Create the video element and add it to the DOM after setting // up event listeners. This ensures the canplay listener is always // fired, triggering runtime.ready(). const video = document.createElement('video'); video.addEventListener('canplay', () => { runtime.ready(); }); video.addEventListener('ended', () => { runtime.complete(); }); video.addEventListener('error', () => { runtime.complete(new Error('Playback error')); }); runtime.subscribe('play', () => { video.play(); }); // Parse the query string to get the video source. video.src = parseVideoFromHashParams(); app.appendChild(video); // This simple video app uses hash params instead of query parameters to demonstrate that // you don't need to use the Raydiant SDK's preview API to receive input value changes for // client-side only apps. Since changing hash parameters don't result in a page reload, the // local file blobs are not lost. window.addEventListener('hashchange', () => { video.src = parseVideoFromHashParams(); video.play(); }); function parseVideoFromHashParams() { const params = new URLSearchParams(window.location.hash.slice(1)); return params.get('video') || '/video.mp4'; }