這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)碛嘘P(guān)使用vue怎么獲取視頻的時(shí)長,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

HTML:
<el-upload class="upload-demo" :action="actionUrl" :show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload"> <button class="ce-button not-hover primary"> <i class="ce-icon_upload"></i> <span>重新上傳</span> </button> </el-upload>
js:
beforeAvatarUpload(file) {
var fileName = file.name || ''
var ext = fileName.split('.')[fileName.split('.').length - 1]
if (ext !== "doc" && ext !== "docx" && ext !== "xls" && ext !== "xlsx"
&& ext !== "ppt" && ext !== "pptx" && ext !== "pdf" && ext !== "mp4") {
this.$notify({
title: "失敗",
message: "上傳資源只能是 doc/docx/xls/xlsx/ppt/pptx/pdf/mp4 格式!",
type: "error",
duration: 3000
});
return false
}
// ppt(10MB),word(10MB),excel(5MB)
if (ext == "doc" || ext == "docx" || ext == "ppt" || ext == "pptx") {
debugger
if (parseInt(file.size) > parseInt('10485760?')) {
this.$notify({
title: "失敗",
message: "上傳word、ppt文件上限為10MB!",
type: "error",
duration: 3000
});
return false
}
}
if (ext == 'mp4') { // 獲取視頻時(shí)長
var url = URL.createObjectURL(file);
var audioElement = new Audio(url);
var duration;
audioElement.addEventListener("loadedmetadata", function (_event) {
duration = audioElement.duration; //時(shí)長為秒,小數(shù),182.36
this.$parent.$data.wDuration = parseInt(duration)
console.log(duration);
});
}
this.$parent.$data.wFileName = file.name
this.$parent.$data.wSize = parseFloat(file.size / 1024).toFixed(2) //獲取文件大小
}上述就是小編為大家分享的使用vue怎么獲取視頻的時(shí)長了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
分享題目:使用vue怎么獲取視頻的時(shí)長-創(chuàng)新互聯(lián)
鏈接分享:http://chinadenli.net/article38/cogopp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、網(wǎng)站導(dǎo)航、手機(jī)網(wǎng)站建設(shè)、品牌網(wǎng)站建設(shè)、Google、網(wǎng)站改版
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容