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