Skip to content

Commit

Permalink
Resume audio context on start in case browser locked it
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Apr 30, 2024
1 parent 883a336 commit 83ae675
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ export function createMetronome(config: MetronomeConfig = {}) {
function start () {
if (interval) return // already running

// play silent buffer to unlock the audio context
// Unlock the audio context
audioContext.resume()
const buffer = audioContext.createBuffer(1, 1, 22050);
const node = audioContext.createBufferSource();
node.buffer = buffer;
Expand Down

0 comments on commit 83ae675

Please sign in to comment.