import { useState, useEffect, lazy, Suspense } from 'react'; import { useParams, Link } from 'react-router-dom'; import { apiFetch } from '../lib/api'; // Lazy — HLS/DASH chunks ne chargent que sur /video/:id, pas sur la homepage const ReactPlayer = lazy(() => import('react-player')); interface Video { id: number; title: string; description: string; duration?: number; storageType: 'youtube' | 's3' | 'local'; storageKey: string; thumbnailUrl?: string; requiredLevel: number; locked: boolean; } interface VideoResponse { success: boolean; data: { video: Video }; } function buildPlayerUrl(storageType: Video['storageType'], storageKey: string): string { switch (storageType) { case 'youtube': return `https://www.youtube.com/watch?v=${storageKey}`; case 's3': return storageKey; // URL S3 complète attendue dans storageKey case 'local': return `${import.meta.env.VITE_API_URL}/stream/${storageKey}`; } } export default function VideoPage() { const { id } = useParams<{ id: string }>(); const [video, setVideo] = useState