Reputation: 723
I am trying to add voice record feature in a chat application ,I have tried this package react-mic it work fine and it give me this data when I stopped the record
I want now to send this as a binary file to the backend I have tried this
let name = `test.ogg`
let lastModified = new Date()
let file = new File([{...audioData.blob,name,lastModified}],name,{
type:"audio/ogg"
})
but it didn't work as expected It change it to binary but it is not a valid file because when I try to change it and played it in the browser it didn't work ,I have read alot of articles but nothing help
and for the method I used I have follow this article https://pqina.nl/blog/convert-a-blob-to-a-file-with-javascript/
Upvotes: 2
Views: 3905
Reputation: 723
I will put this here in case someone want to do the same thing
After trying alot with different packages I used the MediaStream Recording api it is really easy to use and it give me the result I want
This is the url for the documentation https://developer.mozilla.org/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API
Upvotes: 3