JSFiddle - React, Tailwind, and code Playground
HTML
<input type="file" id="fileInput">
<div> duration: <span id='sp'></span>
<div>
JavaScript
var fileInput = document.getElementById('fileInput');
var sp = document.getElementById('sp');
fileInput.onchange = function(){
var file = fileInput.files[0];
var reader = new FileReader();
reader.onload = function() {
var aud = new Audio(reader.result);
aud.onloadedmetadata = function(){
sp.innerHTML = aud.duration;
};
};
reader.readAsDataURL(file);
};