0

How to handle “Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.” with Chrome 85? I'm trying to use autoplay (with a jquery plugin).

HTML code:

<audio loop id="scrollaudio" src="sound/stranger.mp3"></audio>

JavaScript code:

<script> $(function() { var first = new AudioFade('#scrollaudio', 100, 3300, 700).init();
document.querySelector('button').addEventListener('click', function() { { var context = new AudioContext(); // Setup all nodes ... });

How can i fix this in a way that the user interact with the page first? Thanks to all.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445

1 Answers1

-1

make a loading screen that the user has to click before going into the site, that way you now access to play audio as you please on the page. I did it that way here: https://www.tochibedford.com

Tochi Bedford
  • 354
  • 1
  • 9