This commit is contained in:
weipengfei 2023-10-12 19:17:11 +08:00
parent 637c7d0c47
commit cb3032513c
1 changed files with 6 additions and 3 deletions

View File

@ -93,6 +93,7 @@ async function handleCopy() {
} }
let playIndex = 0; let playIndex = 0;
let playing = false;
async function radioPlay() { async function radioPlay() {
console.log('播放', props.mp3) console.log('播放', props.mp3)
const socket = new WebSocket('wss://chat.lihaink.cn/zhanti/tts'); const socket = new WebSocket('wss://chat.lihaink.cn/zhanti/tts');
@ -128,7 +129,7 @@ async function radioPlay() {
onAudioEnd(playIndex) onAudioEnd(playIndex)
}) })
audioElements.push(a) audioElements.push(a)
if(playIndex==0) playAudio() if(playing==false) playAudio()
} }
// for (let i = 0; i < props.mp3.length; i++) { // for (let i = 0; i < props.mp3.length; i++) {
@ -143,8 +144,10 @@ async function radioPlay() {
} }
const onAudioEnd = (index: any) => { const onAudioEnd = (index: any) => {
if (index + 1 < audioElements.length) if (index + 1 < audioElements.length&&playing==false){
audioElements[index + 1].play() audioElements[index + 1].play()
playing = true;
}else playing = false;
} }
// //
const audioElements = reactive([]) const audioElements = reactive([])