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

最近在开发一个网站时,有个需要是 如果有新预警信息要在网页中播放提示音。页面打开会请求是否有新信息,有则播放提示音。在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

时间: 2024-07-29 08:22:34

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

Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause().

解决方法: audio.load() let playPromise = audio.play() if (playPromise !== undefined) { playPromise.then(() => { audio.play() }).catch(()=> { }) } 原因: 从Chrome50开始,对<video>或<audio>元素的play()调用返回一个Promise. 一个异步返回单个结果的函数.如果回放成功,Promise就会实现,而play事

关于 Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause() 错误

最近在做项目的时候发现一个如题的控制台报错. 一看右侧的报错文件是undefined 这下苦恼了,定位不到问题所在. 今天解决了这个问题,就来分享一下. 问题的关键所在是在执行了play()方法以后立即执行pause()方法.反之亦然 以下贴出代码 HTML: <button id="btn1">test</button> JS: var music=new Audio();music.src="/1.mp3";//这里替换成一个有效的音频文

php错误:Uncaught exception com_exception with message Failed to create COM object

本文为大家讲解的是php错误:Uncaught exception com_exception with message Failed to create COM object,感兴趣的同学参考下. 错误: Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `InternetExplorer.Application': 拒绝访问 在PHP中调用IE使用如下代码: br

Uncaught (in promise)

如果promise中 reject的错误没有被catch出来就会报这个错误 // Uncaught (in promise) let a = new Promise((resove,reject)=>{ reject(1) } // ok let a = new Promise((resove,reject)=>{ reject(1) }.then((res)=>{},(err)=>{}) // Uncaught (in promise) let b = new Promise((

Vue ElementUI Axios报错: Uncaught (in promise) TypeError: Cannot read property &#39;$message&#39; of undefined

从头再来!!! 出错的代码如下: login() { this.loading = true let userInfo = {account: this.loginForm.account, password: this.loginForm.password, captcha: this.loginForm.chptcha} this.$api.login.login(userInfo).then( function(res) { if (res.msg != null) { this.$mes

vue-router点击菜单栏同一个模块报错 ———— Uncaught(in promise) NavigationDuplicated error .......

在做移动端底部导航时,鼠标双击各个选项会报如下错误,但是单击时不会出现任何问题. 出现这个bug的原因就是vue-router版本问题,vue-router 3.0版本以上的回调形式是promise api的形式,返回的是一个promise,如果没有捕获到错误,控制台始终会出现上图的警告: 解决方法之可以是安装低版本的vue-router或者捕获抛出放入错误: 解决方法大概包括以下3种解决方法: 1)删除node_modules文件夹,然后使用“cnpm install”重新安装依赖(ps:尝试

uploadify上传错误:uncaught exception: call to startUpload failed原因

这个不是什么tab的问题,而是可能有多个上传的div或者input(含有相同的name或者ID)导致的 如果有两个不同的上传按钮,那么他们的name,id要设置得不一样. <div id='total'> <input type="file" name="total_upload" id="total_upload" multiple="true" /> </div> <a href=

PHP Fatal error: Uncaught ErrorException: preg_match_all (): JIT compilation failed: no more memory in phar

PHP 升级到 7.3 后,出现 BUG: 解决办法:修改php.ini文件,;pcre.jit=1 =>  pcre.jit=0 原文地址:https://www.cnblogs.com/peteremperor/p/10545032.html

vue router 报错: Uncaught (in promise) NavigationDuplicated {_name:&quot;&quot;NavigationDuplicated&quot;... 的解决方法

今天在写vue-music的时候,发现每次跳转路由都会出现这个错误,于是上网查了一下解决的方法 在main.js中添加 import Router from 'vue-router' const originalPush = Router.prototype.push Router.prototype.push = function push(location) { return originalPush.call(this, location).catch(err => err) } 原文地址