Преглед изворни кода

feat: 设置重播按钮跳回初始视频

linjw пре 2 месеци
родитељ
комит
cb9dfc815e

+ 8 - 0
src/components/XGVideoViewer/hooks/useInitPlayer.js

@@ -120,6 +120,14 @@ const useInitPlayer = (props, emits) => {
     try {
       xgplayer.value = initPlay();
       initHandler(xgplayer.value);
+      xgplayer.value.useHooks('replay', (player, ...args) => {
+        if (historyListRef.value[0] === props.videoUrl) {
+          return true
+        } else {
+          emits('reload', historyListRef.value[0])
+          return false
+        }
+      })
       viewerPostMessage({
         msgType: "video_init",
         content: "视频播放器初始化成功",

+ 1 - 1
src/components/XGVideoViewer/index.vue

@@ -41,7 +41,7 @@ export default {
 import { watch } from "vue";
 import useInitPlayer from "./hooks/useInitPlayer";
 
-const emits = defineEmits("onClickOption", "onFullscreenChange");
+const emits = defineEmits("onClickOption", "onFullscreenChange", 'reload');
 
 const props = defineProps({
   // 问题

+ 7 - 0
src/views/interactVideo/videoManage/index.vue

@@ -107,6 +107,7 @@
         :autoplayMuted="false"
         :poster="videoDetail.data.image"
         @onClickOption="onClickOption"
+        @reload="reload"
       />
     </el-dialog>
   </div>
@@ -251,6 +252,12 @@ const onClickOption = (option) => {
   videoDetail.value = videoData;
 };
 
+// 重播返回第一个视频
+const reload = (url) => {
+  let videoData = videoSource.value.filter((i) => i.data && i.data.url === url)[0]
+  videoDetail.value = videoData
+}
+
 // 将树形数据转化为数组
 const treeToArray = (tree, arr = []) => {
   arr.push(tree);