| @@ -226,6 +226,7 @@ class LiveListenWS { | |||||
| this.audioCtx = new (window.AudioContext || window.webkitAudioContext)({ | this.audioCtx = new (window.AudioContext || window.webkitAudioContext)({ | ||||
| sampleRate: this.sampleRate | sampleRate: this.sampleRate | ||||
| }); | }); | ||||
| this.audioCtx.resume().catch(() => {}); | |||||
| this.nextTime = 0; | this.nextTime = 0; | ||||
| this.started = false; | this.started = false; | ||||
| } | } | ||||
| @@ -233,6 +234,9 @@ class LiveListenWS { | |||||
| _playChunk(buf) { | _playChunk(buf) { | ||||
| const ctx = this.audioCtx; | const ctx = this.audioCtx; | ||||
| if (!ctx) return; | if (!ctx) return; | ||||
| if (ctx.state === 'suspended') { | |||||
| ctx.resume().catch(() => {}); | |||||
| } | |||||
| const samples = new Int16Array(buf); | const samples = new Int16Array(buf); | ||||
| const nFrames = Math.floor(samples.length / this.channels); | const nFrames = Math.floor(samples.length / this.channels); | ||||