我使用ng2-file-upload上传视频,上传时长上限为15分钟。那么,我如何才能在上传到服务器之前获得它的持续时间呢?这些扩展只允许:- -.MOV -.MPEG4 -.AVI -.FLV -.3FPP -.WebM和-.MPEGS。如果有人知道,请回复。
发布于 2017-09-02 02:17:29
您可以在您的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>
https://stackoverflow.com/questions/45982710
复制相似问题