el-upload上傳視頻獲取視頻寬高、時長信息


<el-upload
    :on-change="uploadVideoChange">
    <el-button size="small" type="primary">
        <i class="el-icon-upload" />點擊上傳
    </el-button>
</el-upload>
uploadVideoChange (file, fileList) {
    // 防止觸發兩次
    if (file.status !== 'ready') return
    const getVideoInfo = new Promise((resolve) => {
        const videoElement = document.createElement("video");
        videoElement.src = URL.createObjectURL(file.raw);
        videoElement.addEventListener("loadedmetadata", function () {
            resolve({
          duration: videoElement.duration, height: videoElement.videoHeight, width: videoElement.videoWidth }); }); }); getVideoInfo.then((videoInfo)
=> { console.log(videoInfo); }) }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM