bbloomf / jgabc

http://bbloomf.github.io/jgabc/
The Unlicense
105 stars 50 forks source link

Circumvent new autoplay restrictions on modern browsers #68

Open PurgingPanda opened 1 year ago

PurgingPanda commented 1 year ago

When I try to play the music on: http://bbloomf.github.io/jgabc/transcriber.html

I get the error: "The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. "

Related Stackoverflow: https://stackoverflow.com/questions/55026293/google-chrome-javascript-issue-in-getting-user-audio-the-audiocontext-was-not

If I understand correctly the Audiocontext in Tone.min.js with line !i.context && (i.context = new window.AudioContext, should be created when the user clicks something to circumvent this error.

EDIT: The tones.js library shows how to fix this: https://github.com/Tonejs/Tone.js#starting-audio