Skip to content

Commit

Permalink
Implement compatibility with Chrome 71+ autoplay policy
Browse files Browse the repository at this point in the history
This change adds compatibility with Chrome 71+ by accommodating the autoplay policy, which requires explicitly resuming the AudioContext after user interaction.

Details: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#webaudio
  • Loading branch information
nkaminski committed Aug 2, 2020
1 parent e8ef857 commit a93ee93
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions js/jukebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ var Jukebox = {
document.querySelector("#banner").innerHTML = "Click to start";
let onclick = () => {
document.body.removeEventListener("click", onclick);
// Resume the audio context now that the user has interacted with page
// https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#webaudio
this._ctx.resume();
this._next();
}
document.body.addEventListener("click", onclick);
Expand Down

0 comments on commit a93ee93

Please sign in to comment.