From cb3032513c2095600eaeda52471950888ad45327 Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Thu, 12 Oct 2023 19:17:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/chat/components/Message/index.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/views/chat/components/Message/index.vue b/src/views/chat/components/Message/index.vue index b15a7e2..517fd0e 100644 --- a/src/views/chat/components/Message/index.vue +++ b/src/views/chat/components/Message/index.vue @@ -93,6 +93,7 @@ async function handleCopy() { } let playIndex = 0; +let playing = false; async function radioPlay() { console.log('播放', props.mp3) const socket = new WebSocket('wss://chat.lihaink.cn/zhanti/tts'); @@ -128,7 +129,7 @@ async function radioPlay() { onAudioEnd(playIndex) }) audioElements.push(a) - if(playIndex==0) playAudio() + if(playing==false) playAudio() } // for (let i = 0; i < props.mp3.length; i++) { @@ -143,8 +144,10 @@ async function radioPlay() { } const onAudioEnd = (index: any) => { - if (index + 1 < audioElements.length) - audioElements[index + 1].play() + if (index + 1 < audioElements.length&&playing==false){ + audioElements[index + 1].play() + playing = true; + }else playing = false; } // 创建音频对象的数组 const audioElements = reactive([])