zlwu 1 年之前
父节点
当前提交
1dd1339b4b
共有 1 个文件被更改,包括 8 次插入 和 0 次删除
  1. 8 0
      frontend/src/utils/audioPlayerStreaming.ts

+ 8 - 0
frontend/src/utils/audioPlayerStreaming.ts

@@ -165,6 +165,14 @@ export class StreamingAudioPlayer {
       }
     } finally {
       this.isDecoding = false
+      
+      // 🔑 关键修复:解码完成后,检查是否还有新的音频块需要解码
+      // 这样可以处理在解码过程中新到达的音频块
+      if (this.audioChunks.length > this.decodedChunksCount) {
+        console.log(`🔄 检测到 ${this.audioChunks.length - this.decodedChunksCount} 个未解码的块,继续解码...`)
+        // 使用 setTimeout 避免递归调用栈过深
+        setTimeout(() => this.decodeAndQueue(), 0)
+      }
     }
   }