Okazari / Rythm.js

A javascript library that makes your page dance.
https://okazari.github.io/Rythm.js/
GNU General Public License v3.0
3.93k stars 252 forks source link

🐛Fix AudioContext suspended state due to Chrome new policy #108

Closed maici closed 5 years ago

maici commented 5 years ago

Since Chrome 62 there is a new policy that prevent autoplay, if the AudioContext is created without any user interaction (window.onload for example) the state will be set to "suspended" to prevent autoplay.

https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#webaudio

This fix will check the state before starting the song and resume the AudioContext if it's suspended. Note : that will only work if the start method is called after a user action (ex: click on button).