import { useRef, useState, useEffect, useCallback } from "react"; import { Play, Pause, SkipBack, Volume2, VolumeX, Maximize2, Minimize2, VideoIcon, } from "lucide-react"; import { Label } from "@/components/ui/label"; import { AssetPickerSheet } from "../../AssetPickerSheet"; import { useAssetPreviewSrc } from "@/hooks/useAssetPreviewSrc"; import { MediaFallback } from "@/components/generic/MediaFallback"; import { Spinner } from "@/components/ui/spinner"; import { formatPlayerTime as fmtTime } from "@/utils/format.util"; // ─── VideoBlock (Admin) ─────────────────────────────────────────────────────── export function VideoBlock({ content, onUpdate, readOnly = false }) { const [pickerOpen, setPickerOpen] = useState(false); // content.url is redacted (null) server-side for S3 assets — see // redactS3Url() in controllers/admin/assets.controller.js. Re-resolve // through media.util.js instead of trusting the persisted url/thumbnail. const { src, thumbnailUrl, loading } = useAssetPreviewSrc( { asset_id: content?.asset_id, storage_provider: content?.storage_provider, file_url: content?.url, thumbnail_url: content?.thumbnail_url }, { scope: "admin" }, ); const poster = thumbnailUrl ?? content?.thumbnail_url ?? undefined; const vidRef = useRef(null); const wrapRef = useRef(null); const [playing, setPlaying] = useState(false); const [progress, setProgress] = useState(0); const [currentTime, setCurrentTime] = useState(0); const [totalDuration, setTotalDuration] = useState(0); const [muted, setMuted] = useState(false); const [volume, setVolume] = useState(1); const [overlayVisible,setOverlayVisible]= useState(true); // Native Fullscreen API works on desktop (all browsers) and Android Chrome. // iOS Safari doesn't support Fullscreen API on arbitrary elements at all, so // pseudoFullscreen is a CSS-only (fixed inset-0) fallback that keeps our // custom controls instead of falling back to native