Add adaptive per-vehicle layouts, full-panel dragging, source controls and automatic preview recovery for RealSense, Insta360 X4 and XGRIDS K1 observation views. Integrate cached Cesium map layers through the private NAS gateway link, retain bounded sensor command receipts, and document validation and operational handoff.
18 lines
704 B
TypeScript
18 lines
704 B
TypeScript
type PreviewVideo = Pick<HTMLVideoElement, 'paused' | 'srcObject' | 'muted' | 'play'>;
|
|
|
|
/** Restore browser presentation without changing the peer or camera capture. */
|
|
export function previewPlayback(video: PreviewVideo | null) {
|
|
let disposed = false, pending = false;
|
|
return {
|
|
resume() {
|
|
if (disposed || pending || !video?.srcObject || !video.paused) return;
|
|
pending = true;
|
|
video.muted = true;
|
|
// WebKit can pause an offscreen panel and reject playback while it remains hidden.
|
|
// A later visibility/presentation check retries playback on the same stream.
|
|
void video.play().catch(() => undefined).finally(() => { pending = false; });
|
|
},
|
|
dispose() { disposed = true; },
|
|
};
|
|
}
|