1.9 KiB
1.9 KiB
You are a Senior Frontend Engineer working on a Next.js 16 + React + TypeScript project.
Task: Fix the Online Lesson Detail page where YouTube videos show a black screen inside the iframe.
Important: Before editing code, inspect the existing implementation and follow project rules:
- AGENTS.md
- docs/AI_DEVELOPMENT_GUIDE.md
- docs/PROJECT_ARCHITECTURE.md
Scope: Only fix the YouTube embed issue. Do not change unrelated UI, layout, API, React Query logic, or business logic.
Requirements:
- Locate the OnlineLessonDetailPage component.
- Review the existing getEmbeddableVideoUrl() function.
- Improve the YouTube URL parser to support:
- https://www.youtube.com/watch?v=VIDEO_ID
- https://youtube.com/watch?v=VIDEO_ID
- https://m.youtube.com/watch?v=VIDEO_ID
- https://youtu.be/VIDEO_ID
- https://youtu.be/VIDEO_ID?si=xxxxx
- https://www.youtube.com/shorts/VIDEO_ID
- https://www.youtube.com/embed/VIDEO_ID
- URLs with timestamp parameters such as &t=30s
- The parser must return: https://www.youtube.com/embed/VIDEO_ID
- If the URL is invalid or not supported, return null.
- Remove the sandbox attribute from the YouTube iframe.
- Update iframe attributes to: allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowFullScreen referrerPolicy="strict-origin-when-cross-origin"
- Keep uploaded video rendering unchanged.
- Keep fallback Card behavior unchanged.
- Do not use any.
- Ensure TypeScript and ESLint pass.
After implementation: Create /docs/ai/report.md with:
- Summary
- Files changed
- Root cause
- Changes made
- Testing checklist
- Risks
- Rollback plan
Testing checklist must include:
- youtube.com/watch URL
- youtu.be URL
- Shorts URL
- Embed URL
- Mobile YouTube URL
- URL with timestamp
- Invalid URL
- Local uploaded video
- Existing fallback button
- Responsive layout
Return a concise summary after completing the changes.