diff --git a/packages/web/src/components/game/create/QuizEditor.tsx b/packages/web/src/components/game/create/QuizEditor.tsx index 0a03840..d377fb6 100644 --- a/packages/web/src/components/game/create/QuizEditor.tsx +++ b/packages/web/src/components/game/create/QuizEditor.tsx @@ -274,20 +274,31 @@ const QuizEditor = ({ quizzList, onBack, onListUpdate }: Props) => { el.crossOrigin = "anonymous" el.preload = "metadata" el.src = url + el.load() await new Promise((resolve, reject) => { const cleanup = () => { el.onloadedmetadata = null + el.onloadeddata = null + el.oncanplaythrough = null el.onerror = null } - el.onloadedmetadata = () => { + const done = () => { cleanup() resolve() } + el.onloadedmetadata = done + el.onloadeddata = done + el.oncanplaythrough = done el.onerror = () => { cleanup() reject(new Error("Failed to load media metadata")) } + // safety timeout + setTimeout(() => { + cleanup() + reject(new Error("Timed out loading media metadata")) + }, 5000) }) const duration = el.duration @@ -657,18 +668,20 @@ const QuizEditor = ({ quizzList, onBack, onListUpdate }: Props) => { -
- - - Probes audio/video duration and bumps cooldown/answer time if needed. - -
+ {question.media?.type !== "image" && question.media?.url && ( +
+ + + Probes audio/video duration and bumps cooldown/answer time if needed. + +
+ )}