Open otoinsa opened 6 years ago
Thanks for the compliments.
I don’t think you can avoid this. We are heading to a world where all audio and video media requires an interaction. I’m not a huge fan either. You can design around it by creating a start button?
It's a good idea, but one of the target devices (arcade box) will only have button controls connected to it (directional joystick, 5 action buttons), currently a keypress is not resuming the audio context. :(
I guess I can build with an older version of Chromium for now until the Chrome devs implement some none pointer-device way or resuming audio context...
I wonder if there is there a flag in Chrome to prevent this behavior?
chrome://flags/ does have an "Autoplay policy" flag actually, so far it works. :)
Follow-up article: https://www.bleepingcomputer.com/news/google/google-fixes-issue-that-broke-millions-of-web-based-games-in-chrome/
Looks like they temporarily reverting the change until more developers can integrated interaction-to-play audio. I might add a note about this in the readme because it's an important design consideration.
Sorry to bump an old post--
I added a "start" button that then plays the main menu state and starts the audio. Yet, I still get this warning:
The Web Audio autoplay policy will be re-enabled in Chrome 70 (October 2018). Please check that your website is compatible with it. https://goo.gl/7K7WLu
Is that warning something that always pops up? OR is it telling me my current implementation simply doesn't work correctly? Thanks!
How do we resume the audio context after user interaction?
Based on this setter @OptimusPi I believe you should be able to set paused = false
, ala
PIXI.sound.context.paused = false;
maybe it could be useful for someone, it took me a while sorting out those annoying warnings.
You can load dynamically 'pixi-sound' after a user click/swipe and store it in a lazy loader var.
if (!this.pixiSound) {
this.pixiSound = await import('pixi-sound')
}
then, in order to use it:
this.pixiSound.default
Building off the previous comment, this work well for me:
document.addEventListener('click', async () => {
globalThis.PIXI.sound = (await import('pixi-sound')).default;
}, { once: true });
Hi! First of all - thanks for this great sound library! :)
Since last Chrome update there's a new policy: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#webaudio
Needless to say, I don't like this new policy.
My game audio context gets paused :( Since the game has no mouse intereaction, it never gets resumed.
However if I do press on the canvas with a pointer device, it resumes the audio context. PIXI.sound.resumeAll() does not help either.
Is there no way to work around this?
I really like this library and I've been using it for my game; It's still in active development and pixi-sound is an important part of it.