首页 > 其他 > 详细

Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.

时间:2018-12-03 11:46:40      阅读:1968      评论:0      收藏:0      [点我收藏+]

最近在开发一个网站时,有个需要是 如果有新预警信息要在网页中播放提示音。页面打开会请求是否有新信息,有则播放提示音。在Chrome的最新浏览器中,播放会报错,控制台显示Uncaught (in promise) DOMException: play() failed because the user didn‘t interact with the document first.搜索发现Chrome 66为了避免标签产生随机噪音禁止没有交互前使用js进行播放。最后解决方案为 在chrome地址栏输入chrome://flags/。设置Autoplay policy为No user gesture is required。目前想到的解决方案只有这个了,如果有大神有更好的方案欢迎评论。

Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.

原文:https://www.cnblogs.com/xsong/p/10057555.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!