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([])