joshwcomeau / use-sound

A React Hook for playing sound effects
MIT License
2.75k stars 98 forks source link

The AudioContext was not allowed to start #92

Open snax4a opened 3 years ago

snax4a commented 3 years ago

Hi, use-sound hook produces this warning in Google Chrome and Microsoft Edge browsers.

howler.js?1e5c:2517 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu
setupAudioContext @ howler.js?1e5c:2517

Unfortunately, React does not allow to use hooks inside callbacks so I can't define it inside my onClick handler. Can we somehow get rid of that warning?

luizjr commented 2 years ago

I have same problem!

robksawyer commented 2 years ago

Any workarounds here?

lucasgbsampaio commented 2 years ago

same problem.

bransonngai commented 2 years ago

Same here

shaiq-dev commented 2 years ago

This is not an error, this is the default behaviour according to the new Chrome's Autoplay Policy. https://developer.chrome.com/blog/autoplay/#webaudio