A number of my projects have been affected by the recent policy change Google implemented on audio. If you haven’t seen it yet in projects with audio (appears as a warning in console) here’s the link: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#webaudio.
It says to resume
the sound after the user interacts with something on the page, but I can’t get it to work in any of my projects. Some of them play a sound when the user presses a button, like a character jumping, or when two rigid bodies collide. I don’t know if this is directly affecting the sound component and preventing it from working, but I know it’s a pain to work around.
Hi
We are aware of of this and are looking into a fix. Thanks for reporting it here.
That’s good to hear. I’ve noticed that projects that had published builds before this started happening have no problems playing sounds. Or they didn’t. I had one working a short while ago and now it’s not playing sounds.
I think Google’s policy is a bit complicated like it works sometimes but not others based on various kinda arbitrary criteria.
Thanks for tackling this issue!
I’ve tried to disable the Sound Component at start and just re-enable it when the player presses a button, but it doesn’t solve the problem because it seems the audio context is already created during the loading screen.
Is there a rough estimate on when do expect a fix? 1 week, 1 month…
Best,
Rene
Try adding this code in the initialize function of one of your scripts:
var app = this.app;
var resumeContext = function () {
app.systems.sound.manager.context.resume();
window.removeEventListener('mousedown', resumeContext);
window.removeEventListener('touchend', resumeContext);
};
window.addEventListener('mousedown', resumeContext);
window.addEventListener('touchend', resumeContext);
Hi vaios,
thanks a lot, works like a charm!
Best,
Rene