I am trying to display video duration and I took reference from this answer Get video duration when input a video file given by Kaiido. Here is the code:
<script>
var myVideos = [];
window.URL = window.URL || window.webkitURL;
document.getElementById('fileUp').onchange = setFileInfo;
function setFileInfo() {
var files = this.files;
myVideos.push(files[0]);
var video = document.createElement('video');
video.preload = 'metadata';
video.onloadedmetadata = function() {
window.URL.revokeObjectURL(video.src);
var duration = video.duration;
var duration = (new Date).clearTime()
.addSeconds(duration)
.toString('H:mm:ss');
myVideos[myVideos.length - 1].duration = duration;
updateInfos();
}
video.src = URL.createObjectURL(files[0]);;
}
function updateInfos() {
var infos = document.getElementById('infos');
infos.textContent = "";
for (var i = 0; i < myVideos.length; i++) {
infos.textContent += myVideos[i].duration + '\n';
}
}
</script>
However, I want to insert the value inside tag rather than in tag.
I tried using input tag in place of pre tag but it did not work.