I have a raw audio file like this:
const rawAudio = data:audio/webm;codecs=opus;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQRChYECGFOAZwH/////////FUmpZpkq17GDD0JATYCGQ2hyb21lV0GGQ2hyb21lFlSua7+uvdeBAXPFh+Wa3g0oH66DgQKGhkFfT1BVU2Oik09wdXNIZWFkAQEAAIC7AAA
And I want to get the duration of this audio file.
Here is what I tried:
const onDrop = (file) => {
const audio = document.createElement("audio")
audio.setAttribute("src", URL.createObjectURL(file))
audio.setAttribute("crossorigin", "anonymous")
console.log(audio) //
audio.addEventListener("loadedmetadata", () => {
console.log("loadedmetadata")
const duration = audio.duration
console.log(duration)
})
}
var binaryData = []
binaryData.push(Card.audios.explain[0])
onDrop(new Blob(binaryData))
But loadedmetadata
never fires !!
How would you do that?