zlwu hace 1 año
padre
commit
1dd1339b4b
Se han modificado 1 ficheros con 8 adiciones y 0 borrados
  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)
+      }
     }
   }