fix: improve text handling and playback conditions in ChatOperationButton
--bug=1058408 --user=刘瑞斌 【应用管理】移动端自动播放没有声音,浏览器可正常播放 https://www.tapd.cn/62980211/s/1729308
This commit is contained in:
parent
b89ee3d174
commit
6369b4fb45
@ -293,7 +293,7 @@ class AudioManage {
|
|||||||
const newTextList = textList.slice(this.textList.length)
|
const newTextList = textList.slice(this.textList.length)
|
||||||
// 没有新增段落
|
// 没有新增段落
|
||||||
if (newTextList.length <= 0) {
|
if (newTextList.length <= 0) {
|
||||||
return
|
return 0
|
||||||
}
|
}
|
||||||
newTextList.forEach((text, index) => {
|
newTextList.forEach((text, index) => {
|
||||||
this.textList.push(text)
|
this.textList.push(text)
|
||||||
@ -429,7 +429,10 @@ class AudioManage {
|
|||||||
}
|
}
|
||||||
if (text) {
|
if (text) {
|
||||||
const textList = this.getTextList(text, is_end ? true : false)
|
const textList = this.getTextList(text, is_end ? true : false)
|
||||||
this.appendTextList(textList)
|
if (this.appendTextList(textList) !== 0) {
|
||||||
|
// 没有新增段落
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 如果存在在阅读的元素则直接返回
|
// 如果存在在阅读的元素则直接返回
|
||||||
if (this.statusList.some((item) => [AudioStatus.PLAY_INT].includes(item))) {
|
if (this.statusList.some((item) => [AudioStatus.PLAY_INT].includes(item))) {
|
||||||
@ -472,7 +475,7 @@ class AudioManage {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
speechSynthesis.speak(audioElement)
|
speechSynthesis.speak(audioElement)
|
||||||
this.statusList[index] = AudioStatus.PLAY_INT
|
this.statusList[index] = AudioStatus.PLAY_INT
|
||||||
}, 100)
|
}, 500)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -533,7 +536,7 @@ onMounted(() => {
|
|||||||
const record_id = data.record_id
|
const record_id = data.record_id
|
||||||
bus.emit('play:pause', record_id)
|
bus.emit('play:pause', record_id)
|
||||||
if (props.data.record_id == record_id) {
|
if (props.data.record_id == record_id) {
|
||||||
if (props.tts && props.tts_autoplay) {
|
if (props.tts && props.tts_autoplay && data.is_end) {
|
||||||
if (audioManage.value) {
|
if (audioManage.value) {
|
||||||
audioManage.value.play(props.data.answer_text, data.is_end)
|
audioManage.value.play(props.data.answer_text, data.is_end)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user