Browse Source

fix: 强制播放

anxiaoxia 1 tháng trước cách đây
mục cha
commit
4a1019f723
1 tập tin đã thay đổi với 18 bổ sung9 xóa
  1. 18 9
      src/views/envmonitor/taiguv1/index.vue

+ 18 - 9
src/views/envmonitor/taiguv1/index.vue

@@ -10,7 +10,9 @@
       :poster="roomInfo.bg"
       :src="roomInfo.video"
       ref="videoRef"
-      @ended="restartVideo"></video>
+      @ended="restartVideo"
+       @pause="forcePlayVideo"
+      ></video>
     <div
       class="video-model"
       v-if="
@@ -171,7 +173,7 @@
 </template>
 
 <script setup>
-import { onMounted, onUnmounted, ref, nextTick } from "vue"
+import { nextTick, onMounted, onUnmounted, ref } from "vue"
 import { useI18n } from "vue-i18n"
 import { useRoute, useRouter } from "vue-router"
 import AirMore from "./components/Air/AirMore.vue"
@@ -188,13 +190,13 @@ import { ENV_CONFIG, FORUMArr, lanageArr, roomSourceData } from "./const"
 const boxLine = require("@/assets/taiguv1/svg/box_line.png")
 // import "vue3-video-play/dist/style.css";
 import {
-  findForServe,
-  httpGetByMeetingId,
-  HttpGetSpaceInfo,
-  queryAirStatus,
-  queryAudioStatus,
-  queryLampStatus,
-  queryScreenCastingStatus
+findForServe,
+httpGetByMeetingId,
+HttpGetSpaceInfo,
+queryAirStatus,
+queryAudioStatus,
+queryLampStatus,
+queryScreenCastingStatus
 } from "@/apis/taiguv1"
 import useDeviceControl from "@/hooks/useDeviceControl"
 import { useStore } from "@/store"
@@ -275,6 +277,13 @@ const restartVideo = () => {
     videoRef.value.play() // 重新播放视频
   }
 }
+const forcePlayVideo = () => {
+  if (videoRef.value) {
+    videoRef.value.play().catch(error => {
+      console.error('视频强制播放失败:', error);
+    });
+  }
+};
 const handleCustomEvent = data => {
   // 处理接收到的数据
   if (data.close) {