我正在使用ng2-file-upload上传视频,上传的最大上传时间为15分钟。那么,在将其上传到服务器之前,我该如何才能获得它的持续时间呢?这些扩展仅允许: - -.mov -.mpeg4 -..avi -.flv -.3fpp -.webm和-.mpegs。如果有人知道,请回复。
您可以在Angular应用程序中包含Vanilla JavaScript进行此操作。
以下将使您持续时间(在MP4上进行测试):
var inputBox = document.getElementById("videoInput")
inputBox.onchange = function(files) {
alert("starting")
var video = document.createElement('video');
alert("video created")
video.preload = 'metadata';
video.onloadedmetadata = function() {
alert("metadata loaded")
var duration = video.duration;
alert("duration is " + duration)
}
var selectedVID = document.getElementById("videoInput").files[0];
video.src = URL.createObjectURL(selectedVID);
}
<div id="input-upload-file">
<p>
Video Upload Duration test
</p>
<input id="videoInput" type="file" class="upload" name="fileUpload">
</div>