mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: improve speech synthesis handling in ChatOperationButton
Some checks are pending
sync2gitee / repo-sync (push) Waiting to run
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:
parent
2ff63d930b
commit
37100281ee
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue