我需要我的网页在不与用户交互的情况下播放音频剪辑,我知道用户体验不好,不应该那样做,但这就是我的客户所要求的。
[我也知道浏览器已阻止了此功能,因此,如果有人可以给我有关如何“破解”此规则的建议(例如带有事件的内容),我将不胜感激。
考虑以下示例,添加autoplay
属性应使音频在加载时播放
figure {
margin: 0;
}
<figure>
<figcaption>Listen to the audio</figcaption>
<audio
autoplay <!-- auto play here -->
controls
src="some audio example">
Your browser does not support the
<code>audio</code> element.
</audio>
</figure>