JSFiddle - React, Tailwind, and code Playground
HTML
<input type="file" id="fileInputSelector" size="60" name="fileInputSelector" multiple>
<div id="musicas">Músicas Carregadas: 0 (Tempo Total: 0 segundos)</div>
JavaScript
var tempoTotal = 0;
$("#fileInputSelector").change(function () {
var quantidadeDeArquivos = this.files.length;
for (var i = 0; i < quantidadeDeArquivos; i++) {
var esteArquivo = this.files[i];
fileB = URL.createObjectURL(esteArquivo);
var audioElement2 = new Audio(fileB);
audioElement2.setAttribute('src', fileB);
audioElement2.onloadedmetadata = function (e) {
tempoTotal = tempoTotal + parseInt(this.duration);
$("#musicas").html("Músicas Carregadas: " + quantidadeDeArquivos + " (Tempo Total: " + tempoTotal + " segundos)");
//alert("loadedmetadata" + tempoTotal);
}
}
tempoTotal = 0;
});