// screens-playout.jsx — Master Control (MCR) playout page. // // Operator workflow (Phase A — playlist player): // 1. Create / pick a channel (output target: SRT / RTMP / NDI / DeckLink). // 2. Start the channel → spawns the CasparCG sidecar, brings up the output. // 3. Drag assets from the media bin into the playlist; reorder by dragging. // Each item stages from S3 to the CasparCG /media volume in the background. // 4. Hit PLAY → the engine walks the playlist gaplessly. PAUSE / SKIP / STOP // transport. As-run log records what aired. // // Talks to /api/v1/playout via window.ZAMPP_API.fetch. Native HTML5 drag-drop, // no extra library. Components are plain globals (esbuild bundle:false). const PO_OUTPUTS = [ { value: 'srt', label: 'SRT' }, { value: 'rtmp', label: 'RTMP' }, { value: 'ndi', label: 'NDI' }, { value: 'decklink', label: 'SDI (DeckLink)' }, ]; const PO_FORMATS = ['1080p5994', '1080i5994', '1080p2997', '720p5994', '1080i50', '1080p25']; async function poFetch(path, opts) { return window.ZAMPP_API.fetch('/playout' + path, opts); } // ── Helpers ────────────────────────────────────────────────────────────────── function fmtDuration(secs) { if (!secs || secs < 0) return '—'; const s = Math.floor(secs); const h = Math.floor(s / 3600); const m = Math.floor((s % 3600) / 60); const ss = s % 60; const mm = String(m).padStart(2, '0'); const ssStr = String(ss).padStart(2, '0'); return h > 0 ? `${h}:${mm}:${ssStr}` : `${m}:${ssStr}`; } function itemEffectiveDuration(it) { const total = (it.asset_duration_ms || 0) / 1000; const inPt = it.in_point != null ? Number(it.in_point) : 0; const outPt = it.out_point != null ? Number(it.out_point) : total; return Math.max(0, outPt - inPt); } // ── Output-config sub-form (varies by output type) ─────────────────────────── function OutputConfigFields({ type, config, onChange }) { const set = (k, v) => onChange({ ...config, [k]: v }); if (type === 'decklink') { return (
set('device_index', parseInt(e.target.value, 10) || 1)} />
); } if (type === 'ndi') { return (
set('ndi_name', e.target.value)} />
); } // srt / rtmp return (
set('url', e.target.value)} />
{type === 'rtmp' && (
set('key', e.target.value)} />
)} {type === 'srt' && (
set('latency', parseInt(e.target.value, 10) || 200)} />
)}
); } // ── Channel create modal ───────────────────────────────────────────────────── function ChannelCreate({ onClose, onCreated }) { const PROJECTS = window.ZAMPP_DATA?.PROJECTS || []; const [name, setName] = React.useState(''); const [outputType, setOutputType] = React.useState('srt'); const [config, setConfig] = React.useState({}); const [videoFormat, setVideoFormat] = React.useState('1080i5994'); const [projectId, setProjectId] = React.useState(PROJECTS[0]?.id || ''); const [busy, setBusy] = React.useState(false); const [err, setErr] = React.useState(null); const submit = async () => { setBusy(true); setErr(null); try { const ch = await poFetch('/channels', { method: 'POST', body: JSON.stringify({ name, output_type: outputType, output_config: config, video_format: videoFormat, project_id: projectId || null, }), }); onCreated(ch); } catch (e) { setErr(e.message || 'Failed to create channel'); } finally { setBusy(false); } }; return (
e.stopPropagation()} style={{ maxWidth: 460 }}>

New Playout Channel

setName(e.target.value)} placeholder="Channel 1" />
{err &&
{err}
}
); } // ── Media bin: assets draggable into the playlist ──────────────────────────── function MediaBin({ projectId }) { const ASSETS = (window.ZAMPP_DATA?.ASSETS || []).filter(a => !projectId || a.project_id === projectId); const [q, setQ] = React.useState(''); const filtered = ASSETS.filter(a => !q || (a.name || '').toLowerCase().includes(q.toLowerCase())); const onDragStart = (e, asset) => { e.dataTransfer.setData('application/x-df-asset', JSON.stringify({ id: asset.id, name: asset.name })); e.dataTransfer.effectAllowed = 'copy'; }; return (
Media Bin setQ(e.target.value)} style={{ maxWidth: 160 }} />
{filtered.length === 0 &&
No assets.
} {filtered.map(a => (
onDragStart(e, a)} title="Drag into the playlist"> {a.name} {a.duration || ''}
))}
); } // ── Staging progress bar ────────────────────────────────────────────────────── function StagingBar({ status }) { return (