ct 1 місяць тому
батько
коміт
40d3b5bbf0
1 змінених файлів з 5 додано та 2 видалено
  1. 5 2
      src/views/course/videoResource/index.vue

+ 5 - 2
src/views/course/videoResource/index.vue

@@ -1688,11 +1688,14 @@ export default {
       this.uploadQueue.push(tempVideo);
       this.videoList.unshift(tempVideo);
 
-      // 获取视频时长
+       // 获取视频时长
       const video = document.createElement('video');
       video.preload = 'metadata';
       video.onloadedmetadata = () => {
-        tempVideo.duration = Math.round(video.duration);
+        const index = this.videoList.findIndex(item => item.tempId === tempVideo.tempId);
+        if (index !== -1) {
+          tempVideo.duration = Math.round(video.duration);
+        }
       };
       video.src = URL.createObjectURL(file);