简体   繁体   English

如何自动播放 html 音频标签中的 saavan 链接?

[英]How to autoplay the saavan link in html audio tag?

I have welcome.html file in that i have one audio tag inside that source attribute i am adding link from the jio-saavan but it's not playing when the webpage is opened but in console i am getting following error..我有welcome.html 文件,因为我在该源属性中有一个音频标签,我正在添加来自jio-saavan链接,但是当网页打开时它没有播放,但在控制台中我收到以下错误..

Error on console

welcome.html:28 Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.
<audio  autoplay id="my_audio">
  <source src="https://docs.google.com/uc?export=download&id=11wfYWiukbIZJQnDL385jQs2SGQA5ESbL" type="audio/mpeg">
</audio>
<script>
document.getElementById('my_audio').play();
</script>

The error is telling you clearly that you can't start an audio (or even a video if not muted) if the user haven't interacted with the page before.该错误清楚地告诉您,如果用户之前未与页面交互,则无法启动音频(如果未静音,甚至无法启动视频)。

Some links to better help you understand the policy on autoplay:一些可以帮助您更好地了解自动播放政策的链接:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM