Commit 13b6278a by haojie

回复页面也在轮询的bug

parent 4532a364
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
:disabled="disabled" :disabled="disabled"
v-model:value="soundColorValue" v-model:value="soundColorValue"
:list="lists.soundColor" :list="lists.soundColor"
:reset="true"
@itemChange="soundColorItemChange" @itemChange="soundColorItemChange"
> >
<div> <div>
...@@ -173,14 +174,19 @@ const submit = async () => { ...@@ -173,14 +174,19 @@ const submit = async () => {
} }
try { try {
loading.value = true; loading.value = true;
let res: any = await liveInteractionReply(route.query.id, { let params = {
phonetic_timbres_id: soundColorValue.value, phonetic_timbres_id: soundColorValue.value,
reply_content: textareaValue.value, reply_content: textareaValue.value,
tone_id: textTonesValue.value, tone_id: textTonesValue.value,
}); };
if (res.code == 0) { let res: any = await liveInteractionReply(route.query.id, params);
if (res.code == 0 && res.data.status) {
console.log('播放音频');
// 播放音频 // 播放音频
emit('createAudio', res.data.status); emit('createAudio', res.data.status);
} else {
console.log('没有音频', res.data);
console.log(route.query.id, params);
} }
loading.value = false; loading.value = false;
} catch (e) { } catch (e) {
...@@ -214,7 +220,7 @@ const onJump = () => { ...@@ -214,7 +220,7 @@ const onJump = () => {
}; };
onMounted(async () => { onMounted(async () => {
let res = await getTonesList(); let res = await getTonesList(true);
lists.tones = res.tones; lists.tones = res.tones;
lists.soundColor = res.soundColor; lists.soundColor = res.soundColor;
}); });
......
...@@ -44,142 +44,6 @@ const audioEnded = () => { ...@@ -44,142 +44,6 @@ const audioEnded = () => {
// 通知python将直播页面的音量恢复 // 通知python将直播页面的音量恢复
callPyjsInWindow('videoVolumeRestoration'); callPyjsInWindow('videoVolumeRestoration');
}; };
// 定时检测python的方法是否注入成功
let interval = null;
// 定时获取直播互动内容
let intervalLive = null;
// 处理后的视频
const realVideo = ref('');
// 新增视频(当前)
const addVideo = ref(imgs.mp4);
// 视频列表
const addVideoList = ref([]);
// 当前播放id
const addVideoId = ref('');
const stopInterval = () => {
window.clearInterval(interval);
clearInterval(interval);
interval = null;
};
// 获取最新的内容
const openInterval = () => {
interval = window.setInterval(() => {
// 找到第一个没有播放的
for (let i = 0; i < addVideoList.value.length; i++) {
let item = addVideoList.value[i];
if (item.play_status === false && item.remove) {
// 已有取走的任务正在执行
// console.log('已有取走的任务正在执行');
break;
}
if (item.play_status === false && item.remove === false) {
if (addVideo.value == item.reply_content) {
// 本次播放的视频与上次一致,通知视频模块重新播放
store.commit('live/videoReload');
// console.log('本次视频与上次一致');
}
addVideoList.value[i].remove = true;
addVideo.value = item.reply_content;
addVideoId.value = item.id;
break;
}
}
}, 100);
};
// 获取直播互动内容
const getLive = async () => {
try {
let res: any = await getliveTaskReply(route.query.id);
if (res.code == 0 && res.data && res.data.length) {
// if (isDev()) {
// num += 1;
// res.data = [
// {
// id: num,
// reply_content:
// num % 2 == 1
// ? 'https://yunyi-live.oss-cn-hangzhou.aliyuncs.com/live/output/1.mp4'
// : 'http://yunyi-tiktok.oss-cn-shenzhen.aliyuncs.com/files/user/admin/5c8eeb9e-6a7b-45e6-85f9-1c75c945b8b1.mp4',
// },
// {
// id: num++,
// reply_content:
// num % 2 == 1
// ? 'https://yunyi-live.oss-cn-hangzhou.aliyuncs.com/live/output/1.mp4'
// : 'http://yunyi-tiktok.oss-cn-shenzhen.aliyuncs.com/files/user/admin/5c8eeb9e-6a7b-45e6-85f9-1c75c945b8b1.mp4',
// },
// ];
// }
res.data.forEach((item: any) => {
item.play_status = false;
item.remove = false;
});
//id
// problem
// reply_content
addVideoList.value = addVideoList.value.concat(res.data);
}
} catch (e) {
console.log(e);
}
};
// 开启
const startLiveInterval = () => {
closeLiveInterval();
intervalLive = window.setInterval(() => {
getLive();
}, 3000);
};
// 关闭
const closeLiveInterval = () => {
window.clearInterval(intervalLive);
clearInterval(intervalLive);
intervalLive = null;
};
// python 回调
const mergeCallback = (params: any) => {
try {
if (params.video) {
realVideo.value = params.video;
}
if (params.add_video) {
addVideo.value = params.add_video;
}
} catch (e) {
writeLog({
name: 'mergeCallback error',
value: e,
});
console.log(e);
}
};
onMounted(async () => {
// 将通知方法注入window
injectWindow('mergeCallback', mergeCallback);
// if (isDev()) {
// mergeCallback({
// video: imgs.mp4,
// });
// }
// 打开定时任务
startLiveInterval();
openInterval();
});
onBeforeUnmount(() => {
closeLiveInterval();
stopInterval();
});
</script> </script>
<style lang="less"> <style lang="less">
......
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