mirror of
https://github.com/randyjc/Rahoot.git
synced 2026-03-13 20:15:35 +01:00
fix
This commit is contained in:
@@ -33,6 +33,7 @@ const QuestionMedia = ({ media, alt, onPlayChange }: Props) => {
|
|||||||
<div className={clsx(containerClass, "px-4")}>
|
<div className={clsx(containerClass, "px-4")}>
|
||||||
<audio
|
<audio
|
||||||
controls
|
controls
|
||||||
|
crossOrigin="anonymous"
|
||||||
src={media.url}
|
src={media.url}
|
||||||
className="mt-4 w-full rounded-md bg-black/40 p-2 shadow-lg"
|
className="mt-4 w-full rounded-md bg-black/40 p-2 shadow-lg"
|
||||||
preload="none"
|
preload="none"
|
||||||
@@ -48,6 +49,8 @@ const QuestionMedia = ({ media, alt, onPlayChange }: Props) => {
|
|||||||
<div className={containerClass}>
|
<div className={containerClass}>
|
||||||
<video
|
<video
|
||||||
controls
|
controls
|
||||||
|
crossOrigin="anonymous"
|
||||||
|
playsInline
|
||||||
src={media.url}
|
src={media.url}
|
||||||
className="m-4 w-full max-w-3xl rounded-md shadow-lg"
|
className="m-4 w-full max-w-3xl rounded-md shadow-lg"
|
||||||
preload="metadata"
|
preload="metadata"
|
||||||
|
|||||||
@@ -34,19 +34,30 @@ const ensureMediaFolder = () => {
|
|||||||
const inferMimeFromName = (fileName: string) => {
|
const inferMimeFromName = (fileName: string) => {
|
||||||
const ext = path.extname(fileName).toLowerCase()
|
const ext = path.extname(fileName).toLowerCase()
|
||||||
|
|
||||||
if ([".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp", ".svg"].includes(ext)) {
|
const map: Record<string, string> = {
|
||||||
return `image/${ext.replace(".", "") || "jpeg"}`
|
".jpg": "image/jpeg",
|
||||||
|
".jpeg": "image/jpeg",
|
||||||
|
".png": "image/png",
|
||||||
|
".gif": "image/gif",
|
||||||
|
".webp": "image/webp",
|
||||||
|
".bmp": "image/bmp",
|
||||||
|
".svg": "image/svg+xml",
|
||||||
|
".mp3": "audio/mpeg",
|
||||||
|
".m4a": "audio/mp4",
|
||||||
|
".aac": "audio/aac",
|
||||||
|
".wav": "audio/wav",
|
||||||
|
".ogg": "audio/ogg",
|
||||||
|
".oga": "audio/ogg",
|
||||||
|
".flac": "audio/flac",
|
||||||
|
".mp4": "video/mp4",
|
||||||
|
".m4v": "video/mp4",
|
||||||
|
".mov": "video/quicktime",
|
||||||
|
".webm": "video/webm",
|
||||||
|
".ogv": "video/ogg",
|
||||||
|
".mkv": "video/x-matroska",
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([".mp3", ".wav", ".ogg", ".aac", ".m4a", ".flac"].includes(ext)) {
|
return map[ext] || "application/octet-stream"
|
||||||
return `audio/${ext.replace(".", "") || "mpeg"}`
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([".mp4", ".webm", ".mov", ".ogv", ".mkv"].includes(ext)) {
|
|
||||||
return `video/${ext.replace(".", "") || "mp4"}`
|
|
||||||
}
|
|
||||||
|
|
||||||
return "application/octet-stream"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const inferMediaType = (mime: string): QuestionMedia["type"] | null => {
|
const inferMediaType = (mime: string): QuestionMedia["type"] | null => {
|
||||||
|
|||||||
Reference in New Issue
Block a user