Browse Source

充值播放为开头

liushengqiang 1 năm trước cách đây
mục cha
commit
1d9578e10c

+ 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 () => (
     return () => (
       <div class={styles.videoWrap}>
       <div class={styles.videoWrap}>
         <video
         <video
@@ -174,14 +193,19 @@ export default defineComponent({
           onLoadedmetadata={() => {
           onLoadedmetadata={() => {
             data.videoState = 'pause'
             data.videoState = 'pause'
             changePlayBtn('play');
             changePlayBtn('play');
-            handlePlayVideo();
+            nextTick(() => {
+              data.videoContianerRef.currentTime = 0;
+              nextTick(handlePlayVideo)
+            })
           }}
           }}
           onPlay={() => {
           onPlay={() => {
+            videoErrorCount = 0;
             console.log('开始播放')
             console.log('开始播放')
             data.videoState = 'play'
             data.videoState = 'play'
             changePlayBtn('pause')
             changePlayBtn('pause')
             emit('close')
             emit('close')
             emit('play')
             emit('play')
+            clearTimeout(videoErrorTimer)
           }}
           }}
           onPause={() => {
           onPause={() => {
             console.log('暂停播放')
             console.log('暂停播放')
@@ -195,6 +219,7 @@ export default defineComponent({
             changePlayBtn('play')
             changePlayBtn('play')
             emit('ended')
             emit('ended')
           }}
           }}
+          onError={handleErrorVideo}
         ></video>
         ></video>
       </div>
       </div>
     )
     )

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

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