使用js调用音频文件报错,错误信息如下:
play() failed because the user didn’t interact with the document first
该报错是浏览器对于自动播放限制抛出的:play方法调用失败,因为用户没有先操作文档【用户没有先去跟网页做交互再执行音频播放】

解决方式:

构建 DOM 元素时先设置 muted="muted" 属性,调用 play 后再修改静音属性试下是否可以正常

<video id="vi" muted=“muted” controls="controls" autoplay = "autoplay"></video>

play() failed because the user didn‘t interact with the document first的更多相关文章

  1. 音频播放时出现 Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. https://goo.gl/xX8pDD

    <audio id="play" controls="controls" loop="loop"> <source src ...

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

    最近在开发一个网站时,有个需要是 如果有新预警信息要在网页中播放提示音.页面打开会请求是否有新信息,有则播放提示音.在Chrome的最新浏览器中,播放会报错,控制台显示Uncaught (in pro ...

  3. 需求:在浏览器加载完毕后,自动播放视频:出现play() failed because the user didn't interact with the document first.错误

    解决方法:给video标签加入<video muted></video> 静音即可. Chrome 66为了避免标签产生随机噪音. 参考链接:https://juejin.im ...

  4. ERROR [localhost-startStop-1] - Context initialization failed org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/ap

    ERROR [localhost-startStop-1] - Context initialization failed org.springframework.beans.factory.Bean ...

  5. JS自动播放音频 无效chrome设置 (Uncaught (in promise) DOMException: play() failed because the user didn't interact)

    Chrome的autoplay政策在2018年4月做了更改.新的行为:浏览器为了提高用户体验,减少数据消耗,现在都在遵循autoplay政策,Chrome的autoplay 政策非常简单 muted ...

  6. Chrome 声音自动播放抱错问题【play() failed】

    Chrome下调用play后抱错:DOMException: play() failed because the user didn't interact with the document firs ...

  7. [JavaScript] audio在浏览器中自动播放

    audio 在浏览器中自动播放 autoplay 属性 autoplay 属性规定一旦音频就绪马上开始播放. 如果设置了该属性,音频将自动播放. 使用 autoplay 属性进行播放 //使用auto ...

  8. [JavaScript] html5 video标签注意事项

    Chrome 66 禁止声音自动播放 声音无法自动播放这个在IOS/Android上面一直是个惯例,桌面版的Safari在2017年的11版本也宣布禁掉带有声音的多媒体自动播放功能,紧接着在2018年 ...

  9. selenium如何处理H5视频

    selenium处理H5视频主要使用的是javascript,javascript函数有内置的对象叫arguments,arguments包含了调用的参数组,[0]代表取第一个值. currentSr ...

  10. 网页视频不能自动播放?HTML5 video报错Uncaught (in promise) DOMException解决方法

    话说发哥四年前写了一个网页,如上图效果,实际网址http://pano.z01.com ,话说做好时是正常的,突然某一天,客户说你这个网站动画不见了,这是什么原因? 结果检查脚本一切正常. 其实也不是 ...

随机推荐

  1. js常用代码整理2

    引用js <script type="text/javascript" src="js/jquery-1.11.2.min.js"></scr ...

  2. 监听 view 初始化时

    new ViewTreeObserverRegister().observe(getContentView(), new ViewTreeObserver.OnGlobalLayoutListener ...

  3. Fortran笔记之过程重载,多态,泛型编程

    参考自Introduction to Modern Fortran for the Earth System Sciences 过程重载 OOP中的另一个重要技术是过程重载(Procedure Ove ...

  4. 面试官:MySQL一千万数据,怎么快速查询?

    前言 面试官:来说说,一千万的数据,你是怎么查询的? me:直接分页查询,使用limit分页. 面试官:有实操过吗? me:肯定有呀 此刻献上一首<凉凉> 也许有些人没遇过上千万数据量的表 ...

  5. Vulnhub 靶场 CORROSION: 2

    Vulnhub 靶场 CORROSION: 2 前期准备 下载地址:https://www.vulnhub.com/entry/corrosion-2,745/ 靶机地址:192.168.147.19 ...

  6. docker的使用以及常用命令

    查看docker镜像仓库中是否存在某个镜像,通常第一个或stars最多的就是我们要是使用的,以nginx为例 # 搜索一下是否存在该镜像文件 docker search nginx # 安装使用该镜像 ...

  7. sshpass免密登录源码剖析

    源码下载地址:https://sourceforge.net/projects/sshpass/ 免密登陆程序sshpass源码解析,短小精悍的程序,非常值得学习!

  8. VUE前端请求跨域问题解决

    解决方法: vue.config.js文件配置: module.exports = { devServer: { open: true, host: '192.168.1.193', port: 80 ...

  9. SQL_SERVER 2000启动问题

    SQL Server evaluation period has expired解决办法 问题现象: 本地计算机 上的 MSSQLSERVER 服务启动后又停止了.一些服务自动停止,如果它们没有什么可 ...

  10. DELL品牌电脑开机显示supportASsiSt丨pre-Boot SyStem Proforman?

    这个问题,我百度了N个网站,得到的结果都是针对老版本BIOS的 https://wen.baidu.com/question/1647310335599401700.html https://zhua ...