Browse Source

自动播放bug

黄琪勇 1 week ago
parent
commit
b5989bce54

+ 7 - 0
src/views/components/element/AudioElement/AudioPlayer.vue

@@ -3,6 +3,7 @@
     <audio
     <audio
       class="audio"
       class="audio"
       ref="audioRef"
       ref="audioRef"
+      :autoplay="autoplayDefault"
       :src="src"
       :src="src"
       @durationchange="handleDurationchange()"
       @durationchange="handleDurationchange()"
       @timeupdate="handleTimeupdate()"
       @timeupdate="handleTimeupdate()"
@@ -97,6 +98,12 @@ watch(
   }
   }
 )
 )
 
 
+// 当没有动画 需要自动播放
+const autoplayDefault = ref(false)
+if (!props.needWaitAnimation && props.autoplay) {
+  autoplayDefault.value = true
+}
+
 const secondToTime = (second = 0) => {
 const secondToTime = (second = 0) => {
   if (second === 0 || isNaN(second)) return "00:00"
   if (second === 0 || isNaN(second)) return "00:00"
 
 

+ 7 - 0
src/views/components/element/VideoElement/VideoPlayer/index.vue

@@ -17,6 +17,7 @@
         class="video"
         class="video"
         ref="videoRef"
         ref="videoRef"
         :src="src"
         :src="src"
+        :autoplay="autoplayDefault"
         :poster="poster"
         :poster="poster"
         webkit-playsinline
         webkit-playsinline
         playsinline
         playsinline
@@ -153,6 +154,12 @@ watch(
   }
   }
 )
 )
 
 
+// 当没有动画 需要自动播放
+const autoplayDefault = ref(false)
+if (!props.needWaitAnimation && props.autoplay) {
+  autoplayDefault.value = true
+}
+
 const secondToTime = (second = 0) => {
 const secondToTime = (second = 0) => {
   if (second === 0 || isNaN(second)) return "00:00"
   if (second === 0 || isNaN(second)) return "00:00"