"use client"; import { useState } from "react"; import MediaPlayer from "../MediaPlayer"; import FileUpload from "../FileUpload"; import { getImageUrl } from "@/lib/api"; export interface Marker { timestamp: number; question: string; options: string[]; correctIndex: number; } interface MediaBlockProps { id: string; title?: string; url: string; type: 'video' | 'audio' | 'image'; config: { maxPlays?: number; currentPlays?: number; show_transcript?: boolean; markers?: Marker[]; }; editMode: boolean; onChange: (updates: { title?: string; url?: string; config?: { maxPlays?: number; currentPlays?: number; show_transcript?: boolean; markers?: Marker[]; } }) => void; transcription?: { en?: string; es?: string; cues?: { start: number; end: number; text: string }[]; } | null; isGraded?: boolean; } export default function MediaBlock({ title, url, type, config, editMode, onChange, transcription, isGraded }: MediaBlockProps) { const [localPlays, setLocalPlays] = useState(config.currentPlays || 0); const [sourceType, setSourceType] = useState<"url" | "upload">( (url.startsWith("/assets/") || url.includes("/assets/")) ? "upload" : "url" ); const maxPlays = config.maxPlays || 0; const isLocked = maxPlays > 0 && localPlays >= maxPlays; const handleEnded = () => { if (maxPlays > 0) { const nextPlays = localPlays + 1; setLocalPlays(nextPlays); onChange({ config: { ...config, currentPlays: nextPlays } }); } }; // Full URL for display (handles relative paths from server) const displayUrl = getImageUrl(url); return (
Throttle cognitive load by limiting session repetition.
Enable for accessibility; disable for auditory tests.
Questions will pause the video at the specified second. Only simple Yes/No questions supported currently.