if(fileLastName=='mp4'){
var binaryData = [];
// 传入file中raw
binaryData.push(file.raw);
//获取视频或者音频时长
var fileurl = URL.createObjectURL(new Blob(binaryData));
//经测试,发现audio也可获取视频的时长
var audioElement = new Audio(fileurl);
audioElement.addEventListener("loadedmetadata", function (_event) {
//audioElement.duration就是视频时长
file.duration = audioElement.duration;
});
}
直接用URL.createObjectURL会报错
记录一下坑位.