Commit a86dda13 by haojie

播放数字人视频改为优先从python获取

parent 5add2379
......@@ -2,7 +2,7 @@
<router-view :class="[mode]" />
</template>
<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted } from 'vue';
import { computed, onMounted } from 'vue';
import { useStore } from 'vuex';
import config from '@/config/style';
import { useREM } from '@/utils/rem';
......@@ -17,14 +17,14 @@ const mode = computed(() => {
return store.getters['setting/mode'];
});
const contextMenuListener = (event: any) => {
event.preventDefault();
};
// const contextMenuListener = (event: any) => {
// event.preventDefault();
// };
// 销毁
const destroyContextMenuListener = () => {
document.removeEventListener('contextmenu', contextMenuListener);
};
// const destroyContextMenuListener = () => {
// document.removeEventListener('contextmenu', contextMenuListener);
// };
onMounted(() => {
store.dispatch('setting/changeTheme', { ...config });
......
......@@ -187,7 +187,6 @@ const updateTime = () => {
};
// 减小正在播放的视频音量
const lowerVideoVolume = () => {
console.error('减小音量');
let num = 0.5;
if (showFirstVideo.value) {
// 第一个正在播放
......@@ -199,7 +198,6 @@ const lowerVideoVolume = () => {
// 恢复音量,两个视频标签都恢复
const videoVolumeRestoration = () => {
console.error('恢复音量');
firstVideoVolume.value = initVolume;
secondVideoVolume.value = initVolume;
};
......
<template>
<div class="custom-earncoins-header" :style="{ backgroundImage: backgroundImage }">
<div class="header-title">
<div class="title_t1">{{ title1 }}</div>
<div class="title_t2">{{ title2 }}</div>
</div>
<div
class="header-assets"
v-if="right"
:style="{
height: height + 'px',
}"
>
<div>{{ title }}</div>
<div class="card-content-box">
<slot name="assets"></slot>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
const props = withDefaults(
defineProps<{
title1: string;
title2: string;
backgroundImage?: string | null;
// 右侧模块的值
right?: boolean;
height?: number;
title?: string;
}>(),
{
backgroundImage: '',
right: false,
height: 160,
title: '',
},
);
</script>
<style lang="less">
@import '@/style/flex.less';
@import '@/style/variables.less';
.custom-earncoins-header {
margin: 0px;
background: url(@/assets/img/EarnCoins.png) no-repeat;
background-size: 100% 40%;
background-attachment: fixed; /*改变背景图的长和宽*/
height: 398px;
.dj(space-between);
padding: @homepadding;
overflow: hidden;
& > * {
margin-top: 100px;
}
.header-title {
.title_t1 {
font-size: 45px;
font-weight: 800;
line-height: 53px;
}
.title_t2 {
font-size: 20px;
line-height: 40px;
font-weight: 800;
max-width: 600px;
}
}
.header-assets {
width: 432px;
border-radius: 14px;
background: #fefefe;
opacity: 0.95;
border: 1.5px solid #e3e3e3;
box-shadow: 30px 28px 20px rgba(16, 16, 16, 0.1);
padding: 30px;
.card-content-box {
.dj(space-between);
flex-wrap: wrap;
row-gap: 12px;
& > * {
width: 50%;
}
& > :nth-child(2n) {
text-align: right;
}
.card-content {
& > :not(:first-child) {
margin-top: 12px;
}
.card-label {
font-weight: 800;
font-size: 16px;
color: #595a5a;
}
.user-assets {
font-weight: 800;
font-size: 16px;
color: #222222;
}
.conversion-assets {
font-weight: 600;
font-size: 12px;
color: #222222;
}
.green {
color: #25a69a;
}
}
}
}
}
</style>
......@@ -158,6 +158,8 @@ const closeLive = async () => {
changeRouteQuery();
// 通知python刷新所有首页的直播列表
callPyjsInWindow('reloadLiveTaskList');
// 通知python关闭视频播放页面
callPyjsInWindow('closeLivePage');
}
} catch (e) {
console.log(e);
......
......@@ -39,6 +39,7 @@ import { createLiveKeys } from '@/service/CreateLive';
import { useLiveInfoSubmit } from '@/hooks/useStoreCommit';
import { getDigitalPeopleList } from '@/service/Common';
import { useRoute } from 'vue-router';
import { callPyjsInWindow } from '@/utils/pyqt';
const [commitInfo] = useLiveInfoSubmit();
const props = withDefaults(
defineProps<{
......@@ -124,14 +125,20 @@ const onSelectChange = (value: string) => {
checkPerson();
};
// 从python获取视频路径
const getVideoPath = async (row: any) => {
let url = await callPyjsInWindow('getDigimonVideo', row, true);
// 将对应的图片传给右侧工具
// store.commit('live/setLiveImage', row.cover_url);
store.commit('live/setLiveImage', url ? url : row.video_url);
};
const onCardChange = (id: string | number, row: any) => {
currentCard.value = id;
commitInfo({
[createLiveKeys.id]: id,
});
// 将对应的图片传给右侧工具
// store.commit('live/setLiveImage', row.cover_url);
store.commit('live/setLiveImage', row.video_url);
getVideoPath(row);
};
// 数字人列表
......
......@@ -79,6 +79,7 @@ import routerConfig from '@/router/tool';
import { useRouter } from 'vue-router';
import { getDigitalPeopleList } from '@/service/Common';
import Button from '@/components/Button.vue';
import { callPyjsInWindow } from '@/utils/pyqt';
const router = useRouter();
......@@ -174,6 +175,17 @@ const getList = async () => {
digitalPeopleList.list = digitalPeopleList.myList.concat(digitalPeopleList.adminList).slice(0, 5);
}
digitalPeopleList.loading = false;
// 通知python下载数字人视频
let oldList = res.adminList.concat(res.myList);
let newList = [];
oldList.forEach((item: any) => {
let obj = {
id: item.id,
video_url: item.video_url,
};
newList.push(obj);
});
callPyjsInWindow('downloadDigitalPeopleVideo', newList);
} catch (e) {
console.log(e);
digitalPeopleList.loading = false;
......
<template>
<div class="start-live-video">
<!-- <Button theme="green" @click="playVideo">开始播放</Button> -->
<AddVideoPlay
v-model:progress="progress"
:playId="playId"
......@@ -12,7 +11,6 @@
</template>
<script lang="ts" setup>
import Button from '@/components/Button.vue';
import { onBeforeUnmount, ref, watch } from 'vue';
import AddVideoPlay from '@/components/AddVideoPlay.vue';
......@@ -50,18 +48,6 @@ const closeInterval = () => {
interval1 = null;
};
const playVideo = () => {
console.log(videoRef1.value);
videoRef1.value.play();
closeInterval();
interval1 = window.setInterval(() => {
// 播放结束
if (videoRef1.value.ended) {
closeInterval();
}
}, 100);
};
onBeforeUnmount(() => {
closeInterval();
});
......
......@@ -24,9 +24,21 @@ export const injectWindow = (key: string, value: any, parent: string = '') => {
/**
* 调用python指定方法
*/
export const callPyjsInWindow = (name: string, value: any = '') => {
export const callPyjsInWindow = (name: string, value: any = '', callback: boolean = false, timeout: number = 1000) => {
try {
window.pyjs[name](JSON.stringify(value));
if (callback) {
// 返回一个Promise
return new Promise(function (resolve, reject) {
window.pyjs[name](JSON.stringify(value), function (response: any) {
// 在这里处理返回的值
resolve(response);
});
setTimeout(() => {
reject(false);
}, timeout);
});
}
return window.pyjs[name](JSON.stringify(value));
} catch (e) {
console.error(e);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment