查找视频文件时长



我正在上传一个视频文件,在上传之前我需要知道要上传的视频的持续时间。我怎样才能找到这个信息?

我正在使用Angular 11.0.9

async upload(event: any){
this.currentFile  = event.target.files[0];
// Upload Logic
}

试试

<input type="file" (change)="fileTake($event)" />
<video width="400" id="video_here" controls>
<source crossorigin />
Your browser does not support HTML5 video.
</video>

on .ts file
fileTake(event) {
var fileUrl = window.URL.createObjectURL(event.target.files[0]);
document.getElementById("video_here").setAttribute("src", fileUrl);
setTimeout(() => {
var myvid = document.getElementById("video_here");
console.log(myvid["duration"]);
}, 2500);
}

Just Try These

getDuration(e) { let duration = e.target.duration;}

. getelementbyid("yourID" .duration

最新更新