From 2244f4e3ec074df8db1b4741a820ef73904ce90d Mon Sep 17 00:00:00 2001 From: jacobxu666 Date: Wed, 5 Aug 2026 23:13:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=9F=E8=AF=BB=E5=BD=95=E9=9F=B3=E4=BC=98?= =?UTF-8?q?=E5=85=88=E9=80=89=20mp4=20=E6=A0=BC=E5=BC=8F(Safari/Chrome=20?= =?UTF-8?q?=E9=80=9A=E7=94=A8),=E8=A7=A3=E5=86=B3=E5=AE=B6=E9=95=BF?= =?UTF-8?q?=E7=AB=AF=20iOS=20=E5=90=AC=E4=B8=8D=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - MediaRecorder 优先 audio/mp4,回退 webm;iOS Safari 可回放 mp4 - 清理历史 webm 录音(无法在 iOS 播放) Co-Authored-By: Claude Opus 4.8 (1M context) --- src/app/words/word-day.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/words/word-day.tsx b/src/app/words/word-day.tsx index b0a83cb..fa1633d 100644 --- a/src/app/words/word-day.tsx +++ b/src/app/words/word-day.tsx @@ -29,7 +29,12 @@ function RecordBtn({ day, word }: { day: number; word: string }) { const start = async () => { try { const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); - const mr = new MediaRecorder(stream); + // 优先选 Safari/Chrome 都能播放的 mp4,家长端 iOS 才能回放 + const mime = + ["audio/mp4", "audio/mp4;codecs=mp4a.40.2", "audio/webm;codecs=opus", "audio/webm"].find( + (t) => typeof MediaRecorder !== "undefined" && MediaRecorder.isTypeSupported(t), + ) || ""; + const mr = new MediaRecorder(stream, mime ? { mimeType: mime } : undefined); const chunks: Blob[] = []; mr.ondataavailable = (e) => chunks.push(e.data); mr.onstop = async () => {