Browse Source

Merge branch 'iteration_0307' into jenkins-main

liushengqiang 1 year ago
parent
commit
a7ff70e0ff

+ 26 - 1
src/views/coursewarePlay/component/video-item/index.tsx

@@ -162,6 +162,25 @@ export default defineComponent({
       })
     }
 
+    let videoErrorTimer = null as any;
+    let videoErrorCount = 0;
+    const handleErrorVideo = () => {
+      if (videoErrorCount > 5) {
+        return;
+      }
+      clearTimeout(videoErrorTimer)
+      nextTick(() => {
+        videoErrorTimer = setTimeout(() => {
+          data.videoContianerRef.src = props.item?.content
+          emit('play')
+          data.videoContianerRef.load()
+          // eslint-disable-next-line @typescript-eslint/no-unused-vars
+          handleErrorVideo();
+        }, 1000)
+      })
+      videoErrorCount++;
+    }
+
     return () => (
       <div class={styles.videoWrap}>
         <video
@@ -174,14 +193,19 @@ export default defineComponent({
           onLoadedmetadata={() => {
             data.videoState = 'pause'
             changePlayBtn('play');
-            handlePlayVideo();
+            nextTick(() => {
+              data.videoContianerRef.currentTime = 0;
+              nextTick(handlePlayVideo)
+            })
           }}
           onPlay={() => {
+            videoErrorCount = 0;
             console.log('开始播放')
             data.videoState = 'play'
             changePlayBtn('pause')
             emit('close')
             emit('play')
+            clearTimeout(videoErrorTimer)
           }}
           onPause={() => {
             console.log('暂停播放')
@@ -195,6 +219,7 @@ export default defineComponent({
             changePlayBtn('play')
             emit('ended')
           }}
+          onError={handleErrorVideo}
         ></video>
       </div>
     )

+ 1 - 3
src/views/coursewarePlay/index.tsx

@@ -658,9 +658,7 @@ export default defineComponent({
                 onEnded={() => {
                   const _index = popupData.activeIndex + 1
                   if (_index < data.itemList.length) {
-                    setTimeout(() => {
-                      handleSwipeChange(_index)
-                    }, 500)
+                    handleSwipeChange(_index);
                   }
                 }}
               />