Skip to content

Commit

Permalink
check if audio context state is suspended in setupAudio function, and…
Browse files Browse the repository at this point in the history
… call resume it is (handles issues on some browsers where the state is not running)
  • Loading branch information
barrymun committed Sep 23, 2023
1 parent 88b9bad commit 972cfa9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/music-visualizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ export class MusicVisualizer {
gainNode.connect(audioContext.destination); // Connect gain node to destination

sourceNode.start();
if (audioContext.state === "suspended") {
await audioContext.resume();
}

this.setSourceNode(sourceNode);
this.setGainNode(gainNode);
Expand Down

0 comments on commit 972cfa9

Please sign in to comment.