Google Chrome Javascript issue in getting user audio - The AudioContext was not allowed to start
you should be able to call resume()
somewhere right before you call play()
. The important thing is to call it within a user action/event - like the click on the microphone button.
Key Point: If an AudioContext is created prior to the document receiving a user gesture, it will be created in the "suspended" state, and you will need to call resume() after a user gesture is received.
from https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
It used to work before on Google Chrome browser as well but now it's not working.
The new policy has been enforced recently within a chrome update.
If your question is related to p5.js when accessing microphone, do this in setup
function setup() {
mic = new p5.AudioIn();
mic.start();
getAudioContext().resume();
}
Or add touchStarted
function the document. You have to click on the web page to trigger this function.
function touchStarted() {
getAudioContext().resume();
}