|
@ -67,10 +67,25 @@ const playNextAudio = () => { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (currentPlayIndex >= audioQueue.value.length) { |
|
|
if (currentPlayIndex >= audioQueue.value.length) { |
|
|
console.log("所有音频播放完成"); |
|
|
|
|
|
isPlayingAudio.value = false; |
|
|
|
|
|
|
|
|
console.log("所有音频播放完成,重置到第一个音频"); |
|
|
|
|
|
// 播放完成后重置到第一个音频,但不自动播放 |
|
|
|
|
|
currentPlayIndex = 0; |
|
|
|
|
|
audioStore.isPlaying = false; |
|
|
|
|
|
audioStore.isPaused = false; |
|
|
|
|
|
audioStore.playbackPosition = 0; |
|
|
|
|
|
// 清除音频实例,确保下次点击从头开始 |
|
|
|
|
|
audioStore.soundInstance = null; |
|
|
|
|
|
audioStore.nowSound = null; |
|
|
|
|
|
if (audioQueue.value.length > 0) { |
|
|
|
|
|
audioStore.setCurrentAudioUrl(audioQueue.value[0]); |
|
|
|
|
|
} |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
// if (currentPlayIndex >= audioQueue.value.length) { |
|
|
|
|
|
// console.log("所有音频播放完成"); |
|
|
|
|
|
// isPlayingAudio.value = false; |
|
|
|
|
|
// return; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
isCallingPlayNext = true; |
|
|
isCallingPlayNext = true; |
|
|
const audioInfo = audioQueue.value[currentPlayIndex]; |
|
|
const audioInfo = audioQueue.value[currentPlayIndex]; |
|
@ -138,6 +153,11 @@ const playNextAudio = () => { |
|
|
audioStore.soundInstance = null; |
|
|
audioStore.soundInstance = null; |
|
|
// currentPlayIndex = 0; |
|
|
// currentPlayIndex = 0; |
|
|
isCallingPlayNext = false; |
|
|
isCallingPlayNext = false; |
|
|
|
|
|
|
|
|
|
|
|
// setTimeout(() => { |
|
|
|
|
|
// isCallingPlayNext = false; |
|
|
|
|
|
// playNextAudio(); |
|
|
|
|
|
// }, 500); // 间隔500ms播放下一个 |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
onstop: () => { |
|
|
onstop: () => { |
|
@ -194,7 +214,11 @@ const addToAudioQueue = (url, name) => { |
|
|
!audioStore.isPlaying && |
|
|
!audioStore.isPlaying && |
|
|
audioQueue.value.length === 1 |
|
|
audioQueue.value.length === 1 |
|
|
) { |
|
|
) { |
|
|
console.log("✅ 条件满足:没有音频在播放且这是第一个音频,立即开始播放"); |
|
|
|
|
|
|
|
|
console.log("✅ 条件满足:没有音频在播放且这是第一个音频,立即开始播放", { |
|
|
|
|
|
isPlayingAudio: isPlayingAudio.value, |
|
|
|
|
|
audioStoreIsPlaying: audioStore.isPlaying, |
|
|
|
|
|
queueLength: audioQueue.value.length, |
|
|
|
|
|
}); |
|
|
playNextAudio(); |
|
|
playNextAudio(); |
|
|
} else { |
|
|
} else { |
|
|
console.log("⏳ 等待条件:", { |
|
|
console.log("⏳ 等待条件:", { |
|
@ -231,13 +255,16 @@ const toggleVoiceForUser = (index) => { |
|
|
) { |
|
|
) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 先把当前按钮状态修改 |
|
|
// 先把当前按钮状态修改 |
|
|
chatStore.messages[index].audioStatus = |
|
|
chatStore.messages[index].audioStatus = |
|
|
!chatStore.messages[index].audioStatus; |
|
|
!chatStore.messages[index].audioStatus; |
|
|
// 如果当前按钮和之前的按钮不是同一个则再修改之前的按钮的状态 |
|
|
// 如果当前按钮和之前的按钮不是同一个则再修改之前的按钮的状态 |
|
|
if (chatStore.currentUserIndex != index) { |
|
|
if (chatStore.currentUserIndex != index) { |
|
|
if (chatStore.currentUserIndex != null) { |
|
|
if (chatStore.currentUserIndex != null) { |
|
|
audioStore.togglePlayPause(); |
|
|
|
|
|
|
|
|
if (audioStore.isPlaying) { |
|
|
|
|
|
audioStore.togglePlayPause(); |
|
|
|
|
|
} |
|
|
chatStore.messages[chatStore.currentUserIndex].audioStatus = false; |
|
|
chatStore.messages[chatStore.currentUserIndex].audioStatus = false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -245,6 +272,22 @@ const toggleVoiceForUser = (index) => { |
|
|
audioPreloadStatus.two = { loaded: false, url: null }; |
|
|
audioPreloadStatus.two = { loaded: false, url: null }; |
|
|
audioPreloadStatus.three = { loaded: false, url: null }; |
|
|
audioPreloadStatus.three = { loaded: false, url: null }; |
|
|
audioPreloadStatus.four = { loaded: false, url: null }; |
|
|
audioPreloadStatus.four = { loaded: false, url: null }; |
|
|
|
|
|
if (chatStore.messages[index].audioArray[0]) { |
|
|
|
|
|
audioPreloadStatus.one.loaded = true; |
|
|
|
|
|
audioPreloadStatus.one.url = chatStore.messages[index].audioArray[0]; |
|
|
|
|
|
} |
|
|
|
|
|
if (chatStore.messages[index].audioArray[1]) { |
|
|
|
|
|
audioPreloadStatus.two.loaded = true; |
|
|
|
|
|
audioPreloadStatus.two.url = chatStore.messages[index].audioArray[1]; |
|
|
|
|
|
} |
|
|
|
|
|
if (chatStore.messages[index].audioArray[2]) { |
|
|
|
|
|
audioPreloadStatus.three.loaded = true; |
|
|
|
|
|
audioPreloadStatus.three.url = chatStore.messages[index].audioArray[2]; |
|
|
|
|
|
} |
|
|
|
|
|
if (chatStore.messages[index].audioArray[3]) { |
|
|
|
|
|
audioPreloadStatus.four.loaded = true; |
|
|
|
|
|
audioPreloadStatus.four.url = chatStore.messages[index].audioArray[3]; |
|
|
|
|
|
} |
|
|
chatStore.currentUserIndex = index; |
|
|
chatStore.currentUserIndex = index; |
|
|
audioQueue.value = []; |
|
|
audioQueue.value = []; |
|
|
isPlayingAudio.value = false; |
|
|
isPlayingAudio.value = false; |
|
@ -270,7 +313,17 @@ const toggleVoiceForUser = (index) => { |
|
|
console.log("1111"); |
|
|
console.log("1111"); |
|
|
audioStore.toggleVoice(); |
|
|
audioStore.toggleVoice(); |
|
|
} else { |
|
|
} else { |
|
|
if (audioStore.currentAudioUrl || audioStore.ttsUrl) { |
|
|
|
|
|
|
|
|
if (currentPlayIndex >= audioQueue.value.length) { |
|
|
|
|
|
console.log("重新开始播放音频序列"); |
|
|
|
|
|
currentPlayIndex = 0; |
|
|
|
|
|
isPlayingAudio.value = false; |
|
|
|
|
|
isCallingPlayNext = false; |
|
|
|
|
|
audioStore.soundInstance = null; |
|
|
|
|
|
// 重新开始播放 |
|
|
|
|
|
if (audioQueue.value.length > 0) { |
|
|
|
|
|
playNextAudio(); |
|
|
|
|
|
} |
|
|
|
|
|
} else if (audioStore.currentAudioUrl || audioStore.ttsUrl) { |
|
|
console.log("2222"); |
|
|
console.log("2222"); |
|
|
audioStore.togglePlayPause(); |
|
|
audioStore.togglePlayPause(); |
|
|
} else { |
|
|
} else { |
|
@ -540,7 +593,7 @@ const playAudioSequence = (audioUrls) => { |
|
|
// 重写togglePlayPause方法以支持音频序列控制 |
|
|
// 重写togglePlayPause方法以支持音频序列控制 |
|
|
const originalTogglePlayPause = audioStore.togglePlayPause; |
|
|
const originalTogglePlayPause = audioStore.togglePlayPause; |
|
|
audioStore.togglePlayPause = () => { |
|
|
audioStore.togglePlayPause = () => { |
|
|
console.log("音频控制按钮被点击"); |
|
|
|
|
|
|
|
|
console.log("音频控制按钮被点击 11111111111"); |
|
|
console.log("当前播放状态:", audioStore.isPlaying); |
|
|
console.log("当前播放状态:", audioStore.isPlaying); |
|
|
console.log("当前暂停状态:", audioStore.isPaused); |
|
|
console.log("当前暂停状态:", audioStore.isPaused); |
|
|
console.log("当前音频实例:", audioStore.soundInstance); |
|
|
console.log("当前音频实例:", audioStore.soundInstance); |
|
@ -1225,7 +1278,7 @@ watch( |
|
|
// 重写audioStore的togglePlayPause方法以支持队列播放控制 |
|
|
// 重写audioStore的togglePlayPause方法以支持队列播放控制 |
|
|
const originalTogglePlayPause = audioStore.togglePlayPause; |
|
|
const originalTogglePlayPause = audioStore.togglePlayPause; |
|
|
audioStore.togglePlayPause = () => { |
|
|
audioStore.togglePlayPause = () => { |
|
|
console.log("主页音频控制按钮被点击22222"); |
|
|
|
|
|
|
|
|
console.log("主页音频控制按钮被点击22222222222222"); |
|
|
console.log( |
|
|
console.log( |
|
|
"当前音频状态 - isPlaying:", |
|
|
"当前音频状态 - isPlaying:", |
|
|
audioStore.isPlaying, |
|
|
audioStore.isPlaying, |
|
|