import { useState, useEffect } from "react"; import { Video } from "lucide-react"; import { KIOSK_EVENT, loadVideoSourceConfig, type VideoSourceConfig, } from "../kioskStorage"; import { PAGE_CONTENT_INSET } from "../pageContentInset"; export function SharedObservatoryPage() { const [videoSource, setVideoSource] = useState(() => loadVideoSourceConfig()); const [hlsPlaybackError, setHlsPlaybackError] = useState(false); useEffect(() => { const sync = () => setVideoSource(loadVideoSourceConfig()); window.addEventListener(KIOSK_EVENT, sync); window.addEventListener("storage", sync); return () => { window.removeEventListener(KIOSK_EVENT, sync); window.removeEventListener("storage", sync); }; }, []); useEffect(() => { setHlsPlaybackError(false); }, [videoSource.protocol, videoSource.url]); const streamUrl = videoSource.url.trim(); const hasStream = streamUrl !== ""; const showHlsPlayer = hasStream && videoSource.protocol === "HLS" && !hlsPlaybackError; const canEmbedByIframe = hasStream && (streamUrl.startsWith("http://") || streamUrl.startsWith("https://")) && (!showHlsPlayer || hlsPlaybackError); return (
{/* 实时视频对接区:占满主区域剩余高度,随屏伸缩 */}

{showHlsPlayer ? (