|
|
@@ -321,11 +321,6 @@ const playDialogueAudio = (isAutoPlay = false) => {
|
|
|
dialogueAudio.value.currentTime = 0
|
|
|
}
|
|
|
|
|
|
- // 如果是诗词类型,不播放音频
|
|
|
- if (currentDialogue.value?.type === 'poem') {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
// 播放当前对话的语音
|
|
|
if (currentDialogue.value?.voiceoverUrl) {
|
|
|
const audio = new Audio(currentDialogue.value.voiceoverUrl)
|
|
|
@@ -400,14 +395,21 @@ const playSequence = () => {
|
|
|
// 显示诗词并替换内容为最新的诗词
|
|
|
showPoem.value = true
|
|
|
currentPoemContent.value = currentDialogue.value.content
|
|
|
- // 自动切换到下一条对话
|
|
|
- setTimeout(() => {
|
|
|
- if (!playNext(true)) {
|
|
|
- // 播放完毕
|
|
|
- isPlaying.value = false
|
|
|
- stopAllAudio()
|
|
|
- }
|
|
|
- }, 500)
|
|
|
+
|
|
|
+ // 检查是否有语音
|
|
|
+ if (currentDialogue.value?.voiceoverUrl) {
|
|
|
+ // 播放诗词语音
|
|
|
+ playDialogueAudio(true)
|
|
|
+ } else {
|
|
|
+ // 没有语音,直接切换到下一条对话
|
|
|
+ setTimeout(() => {
|
|
|
+ if (!playNext(true)) {
|
|
|
+ // 播放完毕
|
|
|
+ isPlaying.value = false
|
|
|
+ stopAllAudio()
|
|
|
+ }
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
} else {
|
|
|
// 播放当前对话语音,传递isAutoPlay参数
|
|
|
playDialogueAudio(true)
|
|
|
@@ -462,13 +464,11 @@ const playPrevious = () => {
|
|
|
|
|
|
// 播放背景音
|
|
|
playBackgroundAudio()
|
|
|
- // 播放当前对话语音(非诗词类型)
|
|
|
- if (currentDialogue.value?.type !== 'poem') {
|
|
|
- if (isPlaying.value) {
|
|
|
- playDialogueAudio(true)
|
|
|
- } else {
|
|
|
- playDialogueAudio()
|
|
|
- }
|
|
|
+ // 播放当前对话语音
|
|
|
+ if (isPlaying.value) {
|
|
|
+ playDialogueAudio(true)
|
|
|
+ } else {
|
|
|
+ playDialogueAudio()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -499,10 +499,21 @@ const playNext = (isAutoPlay = false) => {
|
|
|
// 显示诗词并替换内容为最新的诗词
|
|
|
showPoem.value = true
|
|
|
currentPoemContent.value = currentDialogue.value.content
|
|
|
- // 自动切换到下一条对话,不需要播放音频
|
|
|
- setTimeout(() => {
|
|
|
- playNext(isAutoPlay)
|
|
|
- }, 500)
|
|
|
+
|
|
|
+ // 检查是否有语音
|
|
|
+ if (currentDialogue.value?.voiceoverUrl) {
|
|
|
+ // 播放诗词语音
|
|
|
+ if (isPlaying.value) {
|
|
|
+ playDialogueAudio(true)
|
|
|
+ } else {
|
|
|
+ playDialogueAudio()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 没有语音,直接切换到下一条对话
|
|
|
+ setTimeout(() => {
|
|
|
+ playNext(isAutoPlay)
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
@@ -526,10 +537,21 @@ const playNext = (isAutoPlay = false) => {
|
|
|
// 显示诗词
|
|
|
showPoem.value = true
|
|
|
currentPoemContent.value = currentDialogue.value.content
|
|
|
- // 自动切换到下一条对话,不需要播放音频
|
|
|
- setTimeout(() => {
|
|
|
- playNext(isAutoPlay)
|
|
|
- }, 500)
|
|
|
+
|
|
|
+ // 检查是否有语音
|
|
|
+ if (currentDialogue.value?.voiceoverUrl) {
|
|
|
+ // 播放诗词语音
|
|
|
+ if (isPlaying.value) {
|
|
|
+ playDialogueAudio(true)
|
|
|
+ } else {
|
|
|
+ playDialogueAudio()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 没有语音,直接切换到下一条对话
|
|
|
+ setTimeout(() => {
|
|
|
+ playNext(isAutoPlay)
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
} else {
|
|
|
// 根据是否为自动播放状态决定如何播放语音
|
|
|
if (isPlaying.value) {
|
|
|
@@ -568,10 +590,17 @@ const startPlayback = () => {
|
|
|
// 显示诗词
|
|
|
showPoem.value = true
|
|
|
currentPoemContent.value = currentDialogue.value.content
|
|
|
- // 自动切换到下一条对话
|
|
|
- setTimeout(() => {
|
|
|
- playNext()
|
|
|
- }, 500)
|
|
|
+
|
|
|
+ // 检查是否有语音
|
|
|
+ if (currentDialogue.value?.voiceoverUrl) {
|
|
|
+ // 播放诗词语音
|
|
|
+ playDialogueAudio()
|
|
|
+ } else {
|
|
|
+ // 没有语音,直接切换到下一条对话
|
|
|
+ setTimeout(() => {
|
|
|
+ playNext()
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
} else {
|
|
|
// 播放当前对话语音
|
|
|
playDialogueAudio()
|