给自己做个记录
image.png
checkFile(e) {
let that = this;
if (!e.target.files[0]) {
this.formData = "";
return false;
} else {
let evt = e || window.event;
let file = evt.target.files[0];
var url = URL.createObjectURL(file);
//audio也可获取视频的时长
var audioElement = new Audio(url);
var lastModifiedTime = file.lastModified;
var duration;
var createTime;
let that =this;
audioElement.addEventListener("loadedmetadata",(_event)=>{
if(audioElement.duration<10){
document.getElementById('selectFile').value = null;
this.formData = '';
this.$message({
showClose: true,
message: '录音时长未大于 10 秒!',
type: 'warning'
});
return false;
}
this.audioFileName = file.name;
duration = parseInt(audioElement.duration)*1000;
that.inputFileTime = {
duration: duration,
createTime: parseInt(lastModifiedTime) - duration,
lastModifiedTime :parseInt(lastModifiedTime) ,
size:file.size
}
});
}
网友评论