-
-
Notifications
You must be signed in to change notification settings - Fork 679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"AudioContext was not allowed to start" warning, but not using any audio-related plugins #3407
Comments
Hi @susanBuck, thanks for reporting this! This is a warning rather than an error, and it's an annoying one because the jsPsych code isn't really doing anything wrong here. What's happening is that jsPsych always creates the Audio Context in case it's needed by plugins later on during the experiment. Most browsers require that the user makes some kind of interaction with the page (button cilck, key press) before the page can actually play audio, which makes sense. Unfortunately the browser is warning us that there hasn't been a user interaction at the point when we're creating the Audio Context, even though we're not actually trying to play anything! My suggestion is to ignore this warning. If we do want to get rid of it, we could move the code that creates the Audio Context out of the constructor: jsPsych/packages/jspsych/src/modules/plugin-api/MediaAPI.ts Lines 13 to 21 in 9c6afb8
And put it into any plugin API functions that require the Audio Context - these would check if it exists, and if not, create it. Thoughts @jspsych/core? |
@becky-gilbert - Thanks for the info! I'm teaching a class that uses jsPsych and the students were thrown off by the warning in the console. I've told them they can ignore it and showed how to filter out warnings from the console. |
@susanBuck no problem! Yep, I can see why your students would be thrown off. Ideally jsPsych would not produce unnecessary console warnings since it can confuse new users, plus it makes it harder for all users to notice any other warnings. I don't think this is a high-priority issue for the team right now, but I'll leave this issue open until we decide whether/when to fix it. In the meantime, it's safe to just ignore this. |
Receiving the following warning in Google Chrome (129.0.6668.70) web inspector:
I understand the error occurs because browsers require interaction before allowing audio to play. However, I can recreate the issue in a barebones experiment with no audio-related plugins, just a simple html-keyboard-response.
JavaScript:
HTML:
The text was updated successfully, but these errors were encountered: