-
Notifications
You must be signed in to change notification settings - Fork 831
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
Is SoundJS effected by recent changes to Chrome autoplay? #297
Comments
@cooperate I'm having the same problem. I'm getting, "The AudioContext was not allowed to start." Does anyone have any fixes for this? |
@cooperate I'm having the same problem as well, what should I do for this? |
Fix seems to be to resume the audio context manually with a click handler. I ran across someone having the same issue with a different audio library: Based on the solution posted there, this seems to be working for me in SoundJS. You should be able to throw this in pretty much anywhere, I added it during the initialization phase of a game.
EDIT: Updated code based on danzen's comment below - Should no longer throw errors if WebAudioPlugin hasn't been instantiated |
Noted, thanks for bringing this to our attention. We're already doing similar unlocks on iOS, so we'll look into generalizing these for other browsers and contexts. |
That is working for me. Thanks much!
…-Aaron
On Mon, May 7, 2018 at 10:47 AM, Dakota Ling ***@***.***> wrote:
Fix seems to be to resume the audio context manually with a click handler.
I ran across someone having the same issue with a different audio library:
http://www.html5gamedevs.com/topic/37384-no-sound-or-music-
on-chrome-desktop-windows-10/?tab=comments#comment-213612
Based on the solution posted there, this seems to be working for me in
SoundJS. You should be able to throw this in pretty much anywhere, I added
it during the initialization phase of a game.
var resumeAudioContext = function() {
// handler for fixing suspended audio context in Chrome
try {
if (createjs.WebAudioPlugin.context.state === "suspended") {
createjs.WebAudioPlugin.context.resume();
// Should only need to fire once
window.removeEventListener("click", resumeAudioContext);
}
} catch (e) {
// SoundJS context or web audio plugin may not exist
console.error("There was an error while trying to resume the SoundJS Web Audio context...");
console.error(e);
}
};
window.addEventListener("click", resumeAudioContext);
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#297 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AZqhMZIyePUA5Xvoe7Au6_o2WaM0W-q1ks5twGyCgaJpZM4TzeHB>
.
|
CyanLetter saves the day! Thanks for sharing the fix. FYI, all the sound demos on the SoundJS site are also suffering from the same issue on initial load. Once you click to view a new demo it rights itself due to the use of iFrames (I'm guessing). This is how I confirmed that the error I was seeing was not only in my code. |
Thank you very much. It works perfectly!!! |
Thanks CyanLetter - the code worked on a server but I found, when testing locally, it still gives errors in chrome and stops the code from running in Firefox. I have adjusted the code to at least fix Firefox locally. So much for the try catch - I don't think I have EVER gotten a try catch to work in 30 years of coding.
|
Update for anyone keeping track of this, Google has updated Chrome 66 to temporarily remove the new autoplay policy for the Web Audio API. It appears that everything using SoundJS is working properly again. However, they are planning to add this feature back in Chrome 70 in October, so this is only a temporary fix. Here is the relevant post in the Chrome bug tracker: https://bugs.chromium.org/p/chromium/issues/detail?id=840866#c103 |
Hi I'm using SoundJS in my application but recent changes to Chrome have caused it to stop working.
https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
What should I do to fix this?
The text was updated successfully, but these errors were encountered: