# Adilo Video Player - Quick AI Agent Reference ## For Your Windsurf/IDE AI Agent Copy this into your `.codebase` instructions or share with AI agent: --- ## Project: LearnHub - Adilo M3U8 Video Player with Custom Chapters ### Problem Statement Build a React video player that: - Streams video from Adilo using M3U8 (HLS) direct URL - Displays custom chapter navigation - Allows click-to-jump to chapters - Tracks user progress - Saves completion data to Supabase ### Tech Stack - **React 18+** (Hooks, Context) - **HLS.js** - for M3U8 streaming - **Supabase** - for progress tracking - **HTML5 Video API** - native controls - **CSS Modules** - styling --- ## Quick Command Reference ### Install Dependencies ```bash npm install hls.js @supabase/supabase-js ``` ### Project Structure to Create ``` src/ ├── components/ │ ├── AdiloVideoPlayer.jsx # Main component │ ├── ChapterNavigation.jsx # Chapter sidebar │ └── ProgressBar.jsx # Progress indicator ├── hooks/ │ ├── useAdiloPlayer.js # HLS streaming logic │ └── useChapterTracking.js # Chapter tracking ├── services/ │ ├── adiloService.js # Adilo API calls │ └── progressService.js # Supabase progress ├── styles/ │ └── AdiloVideoPlayer.module.css └── types/ └── video.types.js ``` --- ## Implementation Phases (In Order) ### ⭐ PHASE 1: useAdiloPlayer Hook **Goal**: Get HLS.js working with M3U8 URL **What to build:** - React hook that initializes HLS.js instance - Return: videoRef, isReady, isPlaying, currentTime, duration - Handle browser compatibility (Safari vs HLS.js) - Clean up HLS instance on unmount - Emit callbacks: onTimeUpdate, onEnded, onError **Test with:** ```javascript const { videoRef, currentTime, isReady } = useAdiloPlayer({ m3u8Url: "https://adilo.bigcommand.com/m3u8/...", autoplay: false, onTimeUpdate: (time) => console.log(time) }); ``` --- ### ⭐ PHASE 2: useChapterTracking Hook **Goal**: Determine which chapter is currently active **What to build:** - React hook that tracks active chapter - Input: chapters array, currentTime - Return: activeChapter, activeChapterId, chapterProgress - Detect chapter transitions - Calculate progress percentage **Chapter data structure:** ```javascript { id: "ch1", startTime: 0, endTime: 120, title: "Introduction", description: "Welcome to the course" } ``` **Test with:** ```javascript const { activeChapter, chapterProgress } = useChapterTracking({ chapters: [...], currentTime: 45 }); // activeChapter should be chapter with startTime ≤ 45 < endTime ``` --- ### ⭐ PHASE 3: AdiloVideoPlayer Component **Goal**: Main player combining both hooks **What to build:** - Component that uses both hooks - Renders: