/** * VideoModal Component * * A modal component for displaying videos in fullscreen with detailed information. */ import React, { useEffect } from 'react'; import { type VideoFile } from '../types'; import { VideoPlayer } from './VideoPlayer'; import { VideoDebugger } from './VideoDebugger'; import { useVideoInfo } from '../hooks/useVideoInfo'; import { formatFileSize, formatVideoDate, getFormatDisplayName, getStatusBadgeClass, getResolutionString, formatDuration, isWebCompatible, } from '../utils/videoUtils'; interface VideoModalProps { video: VideoFile | null; isOpen: boolean; onClose: () => void; } export const VideoModal: React.FC = ({ video, isOpen, onClose, }) => { const { videoInfo, streamingInfo, loading, error } = useVideoInfo( video?.file_id || null, { autoFetch: isOpen && !!video } ); // Handle escape key useEffect(() => { const handleEscape = (e: KeyboardEvent) => { if (e.key === 'Escape') { onClose(); } }; if (isOpen) { document.addEventListener('keydown', handleEscape); document.body.style.overflow = 'hidden'; } return () => { document.removeEventListener('keydown', handleEscape); document.body.style.overflow = 'unset'; }; }, [isOpen, onClose]); if (!isOpen || !video) { return null; } const handleBackdropClick = (e: React.MouseEvent) => { if (e.target === e.currentTarget) { onClose(); } }; return (
{/* Backdrop */}
{/* Modal */}
{/* Header */}

{video.filename}

{/* Content */}
{/* Video Player */}
{/* Sidebar with Video Info */}
{/* Status and Format */}
{video.status} {getFormatDisplayName(video.format)} {isWebCompatible(video.format) && ( Web Compatible )}
{/* Basic Info */}

Basic Information

Camera:
{video.camera_name}
File Size:
{formatFileSize(video.file_size_bytes)}
Created:
{formatVideoDate(video.created_at)}
Streamable:
{video.is_streamable ? 'Yes' : 'No'}
{/* Video Metadata */} {videoInfo?.metadata && (

Video Details

Duration:
{formatDuration(videoInfo.metadata.duration_seconds)}
Resolution:
{getResolutionString(videoInfo.metadata.width, videoInfo.metadata.height)}
Frame Rate:
{videoInfo.metadata.fps} fps
Codec:
{videoInfo.metadata.codec}
Aspect Ratio:
{videoInfo.metadata.aspect_ratio.toFixed(2)}
)} {/* Streaming Info */} {streamingInfo && (

Streaming Details

Content Type:
{streamingInfo.content_type}
Range Requests:
{streamingInfo.supports_range_requests ? 'Supported' : 'Not Supported'}
Chunk Size:
{formatFileSize(streamingInfo.chunk_size_bytes)}
)} {/* Loading State */} {loading === 'loading' && (
Loading video details...
)} {/* Error State */} {error && (

Error loading video details

{error.message}

)} {/* Video Debugger (development only) */}
); };