The AudioContext was not allowed to start(解决方案)
浏览器播放音频,显示正在播放中缺没有声音,控制台警告:
The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page.
网上的解决方案是:
chrom浏览器:
地址栏中输入chrome://flags/#autoplay-policy;
将Default
换成No user gesture is required
设置成功但是依然没有效果
然后我在代码中加入了这句就可以了:
navigator.mediaDevices.getUserMedia({ audio: true });
MediaDevices.getUserMedia() 会提示用户给予使用媒体输入的许可,媒体输入会产生一个MediaStream
,里面包含了请求的媒体类型的轨道。getUserMedia的参数是一个包含了video
和 audio
两个成员的MediaStreamConstraints
对象,例如
以下同时请求不带任何参数的音频和视频:
{ audio: true, video: true }
如果设置以上还不行,那就需要你添加一个点击事件,需要播放的时候,模拟点击就可以播放了。
The AudioContext was not allowed to start(解决方案)相关推荐
- 【React-music项目问题】The AudioContext was not allowed to start. It must be resumed (or created) after a
做项目的时候出现的问题:The AudioContext was not allowed to start. It must be resumed (or created) after a user ...
- The AudioContext was not allowed to start. It must be resumed after a user gesture on the page
chrome的The AudioContext was not allowed to start. It must be resumed (or created) after a user gestu ...
- The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on .
音乐自动播放报错 进入配置网站 对浏览器进行配置 edge://flags/#autoplay-policy 搜寻autoplay 将autoplay settings设置为enabled 之后就不会 ...
- Request header field Content-Type is not allowed by Access-Control-Allow-Headers跨域
跨域错误提示: XMLHttpRequest cannot load http://xxx.com. Request header field Content-Type is not allowed ...
- Unity WebGL错误集锦
ips: 0 Unity的PlayerSettings的otherSettings或者Publish Settings里面的Enable Exceptions里面选择Full StackTrace , ...
- Laya Sound
https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/audio https://developer.mozilla.org/zh-CN/ ...
- iOS 9 适配中出现的坑
整理 iOS 9 适配中出现的坑(图文) 2015-10-22 iOS开发 库克表示:"现在在中国有150多万的开发者在iOS当中开发应用程序,我们鼓励更多的人开发应用程序,也鼓励更多的创业 ...
- gitlab镜像仓库设置及自动同步代码到服务器实现方式
描述 最近新接了一个需求,有两个不同的gitlab仓库,隶属于不同的部门,我们需要将其他部门的gitlab代码仓库实时或定时同步到我们的gitlab代码仓库上. 思路 网上调研了下实现方案, 大概有两 ...
- 解决谷歌浏览器不能播放音乐的问题
今天在做egret白鹭播放音乐的时候,在谷歌浏览器一直播放不了 报错: The AudioContext was not allowed to start. It must be resumed (o ...
最新文章
- 【操作系统】【C/C++开发】内存管理
- wamp解决ajax跨域问题
- 社会阶层及由此引起的社会动力学现象
- 直播 | WWW 2021:基于结构增强文本表示学习的知识图谱补全方法
- SAP CRM系统到底有多少种订单类型
- GOOGLE HACKING 系列文章 【FreeXploiT整理收集】
- Docker 的出现
- 记第一次FPV模式飞行穿越机的感受
- 服务器机柜设备信息卡,信息机房标识标准V.doc
- 非常适合新手入门学习的三款建模软件
- 国科大首期“一生一芯”计划初见成效——本科生带着自己设计的处理器芯片毕业
- 【Kanzi】1:android编译环境配置
- Vue项目中 sass安装
- java2017期末考试,2017年java考试模拟试卷(2)
- LeetCode994 Rotting Oranges解题方案
- Under Armour Heat Seeker Performance Review
- 中国飞行娱乐(IFE)市场现状研究分析与发展前景预测报告(2022)
- Halcon 算子 skeleton
- yolov5使用教程训练our数据——手把手教你训练预测(以阿里天池比赛为例)
- 【恒生公司2016研发工程师笔试卷选择题分析】