I'm getting this JavaScript warning on the latest version of Chrome Desktop, which now prevents auto-playing of sound without user interaction: http://bgr.com/2018/03/22/google-chrome-autoplay-videos-sound-block/
So I'm getting this error/warning in my console logs: "The AudioContext was not allowed to start. It must be resume (or created) after a user gesture on the page"
Is there any way for me to resume sounds or the audio context of SoundJS upon user interaction, like a click or keyboard event on the page?
My setup is that I'm using preloadJS to load my MP3s like so:
queue.loadManifest([
{id: 'sndScore', src: 'sndScore.mp3'}
]);
Then I play the sounds like this:
createjs.Sound.play("sndScore");
I tried putting a flag var unitInteracted= false; which I then set to true if the user interacts with the page, and modified my sound playing code like so to make sure that the page has been interacted with before I attempt to play sounds:
if (unitInteracted) {
createjs.Sound.play("sndScore");
}
...but for some reason, I'm still getting the above error/warning and the page ends up still getting muted. Any way to unmute it once Chrome says: "The AudioContext was not allowed to start. It must be resume (or created) after a user gesture on the page"?
Thanks!