fix: improve speech synthesis handling in ChatOperationButton
Some checks are pending
sync2gitee / repo-sync (push) Waiting to run

--bug=1059740 --user=刘瑞斌 【github#3769】应用开启浏览器语音播放,在问答界面,暂停播放后,无法再次开启播放 https://www.tapd.cn/57709429/s/1744903
This commit is contained in:
CaptainB 2025-07-30 11:15:41 +08:00
parent 2ff63d930b
commit 37100281ee

View File

@ -454,14 +454,22 @@ class AudioManage {
this.statusList[index] = AudioStatus.ERROR
}
} else {
if (window.speechSynthesis.paused) {
if (window.speechSynthesis.paused && self) {
window.speechSynthesis.resume()
this.statusList[index] = AudioStatus.PLAY_INT
} else {
if (window.speechSynthesis.pending) {
//
if (window.speechSynthesis.speaking) {
window.speechSynthesis.cancel()
}
speechSynthesis.speak(audioElement)
this.statusList[index] = AudioStatus.PLAY_INT
//
setTimeout(() => {
if (speechSynthesis.speaking) {
return
}
speechSynthesis.speak(audioElement)
this.statusList[index] = AudioStatus.PLAY_INT
}, 500)
}
}
}
@ -482,11 +490,6 @@ class AudioManage {
this.statusList[index] = AudioStatus.READY
if (self) {
window.speechSynthesis.pause()
nextTick(() => {
if (!window.speechSynthesis.paused) {
window.speechSynthesis.cancel()
}
})
} else {
window.speechSynthesis.cancel()
}