简体   繁体   English

如何处理“未捕获(承诺)DOMException:play() 失败,因为用户没有先与文档交互。”?

[英]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.

相关问题 如何处理“未捕获(承诺)DOMException:play() 失败,因为用户没有首先与文档交互。” 在桌面上使用 Chrome 66? - How to handle "Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first." on Desktop with Chrome 66? Uncaught (in promise) DOMException: play() 失败,因为用户没有先与文档交互 - Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first Uncaught (in promise): DOMException: play() failed 因为用户没有首先在控制台中与文档交互 - Uncaught (in promise) : DOMException: play() failed because the user didn't interact with the document first in console 解决 Uncaught (in promise) DOMException: play() failed 因为用户没有先与文档交互 - Solve Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first 出现错误 - Uncaught (in promise) DOMException: play() failed 因为用户没有先与文档交互 - getting error - Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first Error Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first,我该如何解决这个问题? - Error Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first, how can i solve this? 静音的自动播放视频显示错误:play()失败,因为用户没有首先与文档进行交互。 - Muted Autoplay video shows error: play() failed because the user didn't interact with the document first. 在交叉路口播放/暂停带声音的视频 - Chrome - DOMException: play() 失败,因为用户没有先与文档交互 - Play/Pause video with sound on intersection - Chrome - DOMException: play() failed because the user didn't interact with the document first play() 失败,因为用户没有与文档第一次交互 - play() failed because the user didn't interact with the document first issue 获取NotAllowedError:play()失败,因为即使用户按下按键,用户也没有首先与文档进行交互 - Getting NotAllowedError: play() failed because the user didn't interact with the document first even though user is keypressing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM