I want to implement voice message functionlaity in a web chat that uses twilio. And have issue with it not playing in Mac Safari and ios app (the same app that uses twilio as well) devices.
I suppose the problem might be in the mime type of the recorded audio. Here is the code for it:
const mediaRecorder = new window.MediaRecorder(stream, { mimeType: 'audio/webm' });
let chunks = []
mediaRecorder.start()
mediaRecorder.ondataavailable = (e) => chunks.push(e.data)
mediaRecorder.onstop = () => {
chunks = []
}
const formData = new FormData();
const filename = 'recording';
const messageBlob = new Blob(chunks, { type: 'audio/webm' }
formData.append('file', messageBlob, filename)
conversation.sendMessage(formData)
But from what I see in the twilio docs (https://www.twilio.com/docs/sms/accepted-mime-types#accepted-mime-types) it seems they modify it for device compatibility. But the audio is not playable in safari. Is this a bug on twilio side? Or I need to make it browser compatible myself?
Please advise how to make the voice message recorded in web and sent via twilio be played in Mac Safari and ios app.