zero-knowledge file sharing
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

default to mp4/aac for recording

Juliet b7efb2e3 f8b3f6ff

+11 -16
+11 -16
web/src/pages/Upload.tsx
··· 23 23 type Status = "idle" | "encrypting" | "uploading"; 24 24 type View = "result" | "uploading" | "file" | "empty" | "recording"; 25 25 26 - const isIOS = 27 - typeof navigator !== "undefined" && 28 - (/iPad|iPhone|iPod/.test(navigator.userAgent) || 29 - (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1)); 30 - const REC_MIMES = isIOS 31 - ? ["audio/mp4", "audio/webm;codecs=opus", "audio/webm", "audio/ogg;codecs=opus"] 32 - : ["audio/webm;codecs=opus", "audio/webm", "audio/mp4", "audio/ogg;codecs=opus"]; 26 + const REC_MIMES = [ 27 + "audio/mp4;codecs=mp4a.40.2", 28 + "audio/mp4", 29 + "audio/webm;codecs=opus", 30 + "audio/webm", 31 + ]; 33 32 function pickRecMime(): string | null { 34 33 const MR = (window as any).MediaRecorder; 35 34 if (!MR) return null; 36 35 for (const m of REC_MIMES) { 37 36 if (MR.isTypeSupported?.(m)) return m; 38 37 } 39 - return ""; 38 + return null; 40 39 } 41 40 function extForAudio(mimeType: string): string { 42 - const base = mimeType.split(";")[0].toLowerCase(); 43 - if (base.includes("mp4") || base.includes("aac") || base.includes("mpeg")) return "m4a"; 44 - if (base.includes("ogg")) return "ogg"; 45 - if (base.includes("wav")) return "wav"; 46 - return "webm"; 41 + return mimeType.toLowerCase().includes("mp4") ? "m4a" : "webm"; 47 42 } 48 43 49 44 function formatTime(s: number) { ··· 206 201 } catch {} 207 202 208 203 const chunks: BlobPart[] = []; 209 - const mr = new MediaRecorder(mediaStream, pickedMime ? { mimeType: pickedMime } : undefined); 204 + const mr = new MediaRecorder(mediaStream, { mimeType: pickedMime }); 210 205 mediaRecorder = mr; 211 206 mr.ondataavailable = (e) => { 212 207 if (e.data.size > 0) chunks.push(e.data); 213 208 }; 214 209 mr.onstop = () => { 215 - const actualMime = mr.mimeType || pickedMime || "audio/webm"; 216 - const baseType = actualMime.split(";")[0] || "audio/webm"; 210 + const actualMime = mr.mimeType || pickedMime; 211 + const baseType = actualMime.split(";")[0]; 217 212 const ext = extForAudio(actualMime); 218 213 const blob = new Blob(chunks, { type: baseType }); 219 214 const ts = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);