fix: improve speech synthesis handling in ChatOperationButton
--bug=1058147 --user=刘瑞斌 【应用】简易应用-语音播放-浏览器播放-暂停播放后,再点击播放,无响应 https://www.tapd.cn/62980211/s/1727446
This commit is contained in:
parent
b2b144af7c
commit
6773be4fe3
@ -464,11 +464,15 @@ class AudioManage {
|
|||||||
if (window.speechSynthesis.paused) {
|
if (window.speechSynthesis.paused) {
|
||||||
window.speechSynthesis.resume()
|
window.speechSynthesis.resume()
|
||||||
} else {
|
} else {
|
||||||
if (window.speechSynthesis.pending) {
|
// 如果不是暂停状态,取消当前播放并重新开始
|
||||||
|
if (window.speechSynthesis.speaking) {
|
||||||
window.speechSynthesis.cancel()
|
window.speechSynthesis.cancel()
|
||||||
}
|
}
|
||||||
speechSynthesis.speak(audioElement)
|
// 等待取消完成后重新播放
|
||||||
this.statusList[index] = AudioStatus.PLAY_INT
|
setTimeout(() => {
|
||||||
|
speechSynthesis.speak(audioElement)
|
||||||
|
this.statusList[index] = AudioStatus.PLAY_INT
|
||||||
|
}, 100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -489,11 +493,6 @@ class AudioManage {
|
|||||||
this.statusList[index] = AudioStatus.READY
|
this.statusList[index] = AudioStatus.READY
|
||||||
if (self) {
|
if (self) {
|
||||||
window.speechSynthesis.pause()
|
window.speechSynthesis.pause()
|
||||||
nextTick(() => {
|
|
||||||
if (!window.speechSynthesis.paused) {
|
|
||||||
window.speechSynthesis.cancel()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
window.speechSynthesis.cancel()
|
window.speechSynthesis.cancel()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user