ct 1 månad sedan
förälder
incheckning
40d3b5bbf0
1 ändrade filer med 5 tillägg och 2 borttagningar
  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);