[英]How to handle "Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first." on Desktop with Chrome 66?
[英]How to handle “Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.”?
如何处理“未捕获(承诺)DOMException:play() 失败,因为用户没有先与文档交互。” 用 Chrome 85? 我正在尝试使用自动播放(使用 jquery 插件)。
HTML代码:
<audio loop id="scrollaudio" src="sound/stranger.mp3"></audio>
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 ... });
如何以用户首先与页面交互的方式解决此问题? 谢谢大家。
制作一个加载屏幕,用户在进入网站之前必须点击它,这样您现在可以在页面上随意播放音频。 我是这样做的: https : //www.tochibedford.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.