Skip to main content
mercedesc43970157
Participating Frequently
February 28, 2023
Question

Audio Issue: how to call sounds correctly? (Html5 canvas games)

  • February 28, 2023
  • 2 replies
  • 724 views

Hi, 

I´m having an audio issue with several games I have made with  Animate cc html5 canvas. The problem is the " Autoplay policy" of Chrome and other browsers:
 "The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page." 
 
Although my audios starts after the user interacts with the game, this doesn't seem to be enough because the error keeps showing up in the browser.
 
I guess they must be called or declared in a different way than I'm used to.
 
I simply put the sounds on the timeline of a movie clip and then play them, some when the user clicks a button, and others through code when the user hits or misses.
 
I have searched for the solution but I can't find it, I will be very grateful if someone can share their way to use sounds in the correct way.
This topic has been closed for replies.

2 replies

Colin Holgate
Inspiring
March 1, 2023

What kglad said seems right, it takes a user action to have to trigger the sound. One good thing, it's a once per session check, they don't have to click for every time you want to play a sound to them. Make your landing page Start button start the experience, and also play a sound.

kglad
Community Expert
Community Expert
February 28, 2023

i use a landing/welcome/instructions page with no sound.  a button is required to move to the next keyframe where sounds can be started then or thereafter.

mercedesc43970157
Participating Frequently
February 28, 2023

Thanks for your answer, but I assume there is a specific way to declare sounds because I see that just putting them in the Library already generates "The AudioContext was not allowed to start" warning in Chrome, without even using them on stage.
Is it so?

kglad
Community Expert
Community Expert
February 28, 2023

that's a warning and means nothing unless it's re-declared when the sound should start.