소스 검색

fix: resume browser audio context for live listen

master
Jan Svabenik 12 시간 전
부모
커밋
7b8152e33a
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  1. +4
    -0
      web/app.js

+ 4
- 0
web/app.js 파일 보기

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

const samples = new Int16Array(buf);
const nFrames = Math.floor(samples.length / this.channels);


불러오는 중...
취소
저장