I am completely lost and need help here. The code below works just fine in showing duration for each uploaded file but what I want is it show total duration for all files in hh:mm:ss format. Also I would like to add a feature to remove files from the list and which that triggers the subtraction or removal of that particular duration file. Thanks in advance.
var myVideos = [];
window.URL = window.URL || window.webkitURL;
function setFileInfo(files) {
myVideos.push(files[0]);
var video = document.createElement('video');
video.preload = 'metadata';
video.onloadedmetadata = function() {
window.URL.revokeObjectURL(this.src)
var duration = video.duration;
myVideos[myVideos.length-1].duration = duration;
updateInfos();
}
video.src = URL.createObjectURL(files[0]);;
}
function updateInfos(){
document.querySelector('#infos').innerHTML="";
for(i=0;i<myVideos.length;i++){
document.querySelector('#infos').innerHTML += "<div>"+myVideos[i].name+" duration: "+myVideos[i].duration+'</div>';
}
}
<div id="input-upload-file" class="box-shadow">
<span>- Try Upload -</span>
<input type="file" class="upload" id="fileUp" name="fileUpload" onchange="setFileInfo(this.files)">
</div>
<div id="infos"></div>
Aucun commentaire:
Enregistrer un commentaire