[英]How to handle “Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.”?
How to handle “Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.”如何处理“未捕获(承诺)DOMException:play() 失败,因为用户没有先与文档交互。” with Chrome 85?用 Chrome 85? I'm trying to use autoplay (with a jquery plugin).我正在尝试使用自动播放(使用 jquery 插件)。
HTML code: HTML代码:
<audio loop id="scrollaudio" src="sound/stranger.mp3"></audio>
JavaScript code: JavaScript 代码:
<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.谢谢大家。
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我是这样做的: https : //www.tochibedford.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.