Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master'

liyanbo 1 týždeň pred
rodič
commit
d68e99b630
1 zmenil súbory, kde vykonal 43 pridanie a 36 odobranie
  1. 43 36
      src/views/AIPage/aiGenerate/DialogContent.vue

+ 43 - 36
src/views/AIPage/aiGenerate/DialogContent.vue

@@ -156,7 +156,7 @@
 </template>
 
 <script setup>
-import { ref, computed, onMounted, onUnmounted, watch } from 'vue'
+import { ref, computed, onMounted, onUnmounted, watch, nextTick } from 'vue'
 import { useRouter } from 'vue-router'
 import { ArrowLeftBold, CaretLeft, CaretRight, Grid, VideoPlay } from '@element-plus/icons-vue'
 import VoiceInput from '@/components/ai/voice/VoiceInput_Api.vue'
@@ -545,6 +545,9 @@ const playSequence = () => {
         }
       }, 500)
     }
+  } else if (currentDialogue.value?.type === 'video') {
+    // 视频类型对话,不自动播放下一条,等待视频结束事件
+    return
   } else {
     // 播放当前对话语音,传递isAutoPlay参数
     playDialogueAudio(true)
@@ -602,15 +605,17 @@ const playPrevious = () => {
   }
 
   // 播放背景音
-  playBackgroundAudio()
-  // 播放当前对话语音(非诗词类型)
-  if (currentDialogue.value?.type !== 'poem') {
-    if (isPlaying.value) {
-      playDialogueAudio(true)
-    } else {
-      playDialogueAudio()
+  nextTick(() => {
+    playBackgroundAudio()
+    // 播放当前对话语音(非诗词类型)
+    if (currentDialogue.value?.type !== 'poem') {
+      if (isPlaying.value) {
+        playDialogueAudio(true)
+      } else {
+        playDialogueAudio()
+      }
     }
-  }
+  })
 }
 
 const playNext = (isAutoPlay = false) => {
@@ -677,39 +682,41 @@ const playNext = (isAutoPlay = false) => {
     showPoem.value = false
     currentPoemContent.value = ''
     // 播放背景音
-    playBackgroundAudio()
-    // 检查新环节的第一个对话是否为诗词类型
-    if (currentDialogue.value?.type === 'poem') {
-      // 显示诗词
-      showPoem.value = true
-      currentPoemContent.value = currentDialogue.value.content
-
-      // 检查是否有语音
-      if (currentDialogue.value?.voiceoverUrl) {
-        // 播放诗词语音
+    nextTick(() => {
+      playBackgroundAudio()
+      // 检查新环节的第一个对话是否为诗词类型
+      if (currentDialogue.value?.type === 'poem') {
+        // 显示诗词
+        showPoem.value = true
+        currentPoemContent.value = currentDialogue.value.content
+
+        // 检查是否有语音
+        if (currentDialogue.value?.voiceoverUrl) {
+          // 播放诗词语音
+          if (isPlaying.value) {
+            playDialogueAudio(true)
+          } else {
+            playDialogueAudio()
+          }
+        } else {
+          // 没有语音,直接切换到下一条对话
+          setTimeout(() => {
+            playNext(isAutoPlay)
+          }, 500)
+        }
+      } else if (currentDialogue.value?.type === 'video') {
+        // 视频类型对话,隐藏诗词
+        showPoem.value = false
+        currentPoemContent.value = ''
+      } else {
+        // 根据是否为自动播放状态决定如何播放语音
         if (isPlaying.value) {
           playDialogueAudio(true)
         } else {
           playDialogueAudio()
         }
-      } else {
-        // 没有语音,直接切换到下一条对话
-        setTimeout(() => {
-          playNext(isAutoPlay)
-        }, 500)
       }
-    } else if (currentDialogue.value?.type === 'video') {
-      // 视频类型对话,隐藏诗词
-      showPoem.value = false
-      currentPoemContent.value = ''
-    } else {
-      // 根据是否为自动播放状态决定如何播放语音
-      if (isPlaying.value) {
-        playDialogueAudio(true)
-      } else {
-        playDialogueAudio()
-      }
-    }
+    })
     return true
   }
   return false