Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Unable to send voice recording to Whatsapp #26276

Merged
merged 6 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
},
});
5 changes: 4 additions & 1 deletion apps/meteor/app/ui/client/lib/recorderjs/audioEncoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
murtaza98 marked this conversation as resolved.
Show resolved Hide resolved
const bufferWithMagicNo = [magicNoPrefix, ...event.data.buffer];
const blob = new Blob(bufferWithMagicNo, { type: 'audio/mpeg' });
this.emit('encoded', blob);
this.worker.terminate();
break;
Expand Down