Sfoglia il codice sorgente

fix: no timeout processing for initial loading

Casper Dai 3 anni fa
parent
commit
5d5183edef
1 ha cambiato i file con 13 aggiunte e 13 eliminazioni
  1. 13 13
      src/components/external/player.js

+ 13 - 13
src/components/external/player.js

@@ -148,8 +148,8 @@ export default {
       console.log('onVideoPlay')
       this.paused = false
       if (this.loading) {
-        clearTimeout(this.$timer)
         this.loading = false
+        clearTimeout(this.$timer)
         if (this.needPause) {
           this.$player.pause()
         }
@@ -160,27 +160,27 @@ export default {
       this.paused = true
     },
     onTimeUpdate () {
+      console.log('onTimeUpdate')
       if (this.loading) {
-        clearTimeout(this.$timer)
-        const video = this.$refs.video
-        console.log('onTimeUpdate', video?.duration, video?.currentTime)
         this.loading = false
+        clearTimeout(this.$timer)
       }
     },
     onVideoWaiting () {
       console.log('onVideoWaiting')
       if (!this.loading) {
         this.loading = true
-        this.$timer = setTimeout(() => {
-          if (this.loading) {
-            this.destroyPlayer()
-            this.$message({
-              type: 'warning',
-              message: '暂未获取到视频流'
-            })
-          }
-        }, 10000)
       }
+      clearTimeout(this.$timer)
+      this.$timer = setTimeout(() => {
+        if (this.loading) {
+          this.destroyPlayer()
+          this.$message({
+            type: 'warning',
+            message: '暂未获取到视频流'
+          })
+        }
+      }, 10000)
     },
     onVideoError (e) {
       console.log('onVideoError', e)