From 999c9ba93e95eb9988a170b89b3ffa707691d540 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 9 Apr 2025 17:03:22 +0800 Subject: [PATCH] bugfic --- bricks/audio.js | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/bricks/audio.js b/bricks/audio.js index 38fb3ef..532cc76 100644 --- a/bricks/audio.js +++ b/bricks/audio.js @@ -323,53 +323,6 @@ bricks.SttClient = class extends bricks.VBox { } } -bricks.ContinueAudioPlayer = class extends bricks.AudioPlayer { - constructor(opts){ - this.options = opts - this.audioContext = null; - this.nextStartTime = 0; - this.started = false; - this.initAudioContext(); // 初始化音频上下文 - } - initAudioContext() { - this.audioContext = new (window.AudioContext || window.webkitAudioContext)(); - this.nextStartTime = this.audioContext.currentTime; - this.started = true; - } - handleAudioTrack(arrayBuffer) { - this.audioContext.decodeAudioData(arrayBuffer).then(decodedBuffer => { - const source = this.audioContext.createBufferSource(); - source.buffer = decodedBuffer; - source.connect(this.audioContext.destination); - - // 连续播放安排 - const startTime = Math.max(this.audioContext.currentTime, this.nextStartTime); - source.start(startTime); - - this.nextStartTime = startTime + decodedBuffer.duration; - }).catch(err => { - console.error("Error decoding audio data:", err); - }); - } - pauseAudio() { - if (this.audioContext && this.audioContext.state === 'running') { - this.audioContext.suspend().then(() => { - console.log("Audio playback paused."); - }); - } - } - - /** - * ▶️ 恢复音频播放(继续 AudioContext) - */ - resumeAudio() { - if (this.audioContext && this.audioContext.state === 'suspended') { - this.audioContext.resume().then(() => { - console.log("Audio playback resumed."); - }); - } - } -} bricks.Factory.register('AudioPlayer', bricks.AudioPlayer); bricks.Factory.register('AudioRecorder', bricks.AudioRecorder); bricks.Factory.register('SttClient', bricks.SttClient);