From 3aed5a931a33ac240d7c553bfa8fe26a105f1fa8 Mon Sep 17 00:00:00 2001 From: murtaza98 Date: Fri, 15 Jul 2022 17:59:14 +0530 Subject: [PATCH 1/3] [FIX] Unable to send voice recording to Whatsapp --- apps/meteor/app/ui/client/lib/recorderjs/audioEncoder.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/meteor/app/ui/client/lib/recorderjs/audioEncoder.js b/apps/meteor/app/ui/client/lib/recorderjs/audioEncoder.js index 90181e225542..81934c69c191 100644 --- a/apps/meteor/app/ui/client/lib/recorderjs/audioEncoder.js +++ b/apps/meteor/app/ui/client/lib/recorderjs/audioEncoder.js @@ -40,7 +40,10 @@ class AudioEncoder extends Emitter { handleWorkerMessage = (event) => { switch (event.data.command) { case 'end': { - const blob = new Blob(event.data.buffer, { type: 'audio/mpeg' }); + // prepend mp3 magic number to the buffer + const magicNoPrefix = new Int8Array([73, 68, 51, 3, 0, 0, 0, 0, 0, 0]); + const bufferWithMagicNo = [magicNoPrefix, ...event.data.buffer]; + const blob = new Blob(bufferWithMagicNo, { type: 'audio/mpeg' }); this.emit('encoded', blob); this.worker.terminate(); break; From 827ce6ca745d0c2eb1d746e66c37512ce7403148 Mon Sep 17 00:00:00 2001 From: murtaza98 Date: Mon, 25 Jul 2022 16:58:13 +0530 Subject: [PATCH 2/3] Fix incorrect name being set for recorded audio file --- .../ui-message/client/messageBox/messageBoxAudioMessage.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/meteor/app/ui-message/client/messageBox/messageBoxAudioMessage.js b/apps/meteor/app/ui-message/client/messageBox/messageBoxAudioMessage.js index 88f7a4c03c57..ffa433d2733f 100644 --- a/apps/meteor/app/ui-message/client/messageBox/messageBoxAudioMessage.js +++ b/apps/meteor/app/ui-message/client/messageBox/messageBoxAudioMessage.js @@ -154,6 +154,9 @@ Template.messageBoxAudioMessage.events({ const { rid, tmid } = this; const blob = await cancelRecording(instance, rid, tmid); - await fileUpload([{ file: blob, type: 'video', name: `${t('Audio record')}.mp3` }], { input: blob }, { rid, tmid }); + const fileName = `${t('Audio record')}.mp3` + const file = new File([blob], fileName, { type: 'audio/mpeg' }); + + await fileUpload([{ file, type: 'audio/mpeg', name: fileName }], { input: blob }, { rid, tmid }); }, }); From 750d3c7aa2e775fcdac3f6ee3d1405bec7cc9743 Mon Sep 17 00:00:00 2001 From: murtaza98 Date: Mon, 25 Jul 2022 17:11:07 +0530 Subject: [PATCH 3/3] fix prettier issue --- .../app/ui-message/client/messageBox/messageBoxAudioMessage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/meteor/app/ui-message/client/messageBox/messageBoxAudioMessage.js b/apps/meteor/app/ui-message/client/messageBox/messageBoxAudioMessage.js index ffa433d2733f..e1a6c425cbcf 100644 --- a/apps/meteor/app/ui-message/client/messageBox/messageBoxAudioMessage.js +++ b/apps/meteor/app/ui-message/client/messageBox/messageBoxAudioMessage.js @@ -154,7 +154,7 @@ Template.messageBoxAudioMessage.events({ const { rid, tmid } = this; const blob = await cancelRecording(instance, rid, tmid); - const fileName = `${t('Audio record')}.mp3` + const fileName = `${t('Audio record')}.mp3`; const file = new File([blob], fileName, { type: 'audio/mpeg' }); await fileUpload([{ file, type: 'audio/mpeg', name: fileName }], { input: blob }, { rid, tmid });