I'm working on an player and I need to know how to calculate the length of multiple MP3s that are selected on the user's machine by a input
of type file
?
EDIT:
Follow my current code and it does not return the correct value ...
var audioElement2 = document.createElement('audio');
var fill;
var tamanho = 0;
$("#file666").change(function() {
fill = this.files.length;
for (var i = 0; i < fill; i++) {
file3[i] = this.files[i];
fileB = URL.createObjectURL(file3[i]);
audioElement2.setAttribute('src', fileB);
$(audioElement2).on("loadedmetadata", function () {
tamanho = tamanho + parseInt(audioElement2.duration);
});
}
$("#musicas").html("Músicas Carregadas: " + fill + " (Tempo Total: " + tamanho + ")");
});
I'm trying to use a for loop with a variable by adding all mp3's but it does not work, it returns "0" as a result ...