javascript - 隐藏的音频文件不播放
问题描述
我正在尝试在 html 中插入音频文件,但如果我将其设置为隐藏,它就不会播放。
<audio src="file/example.ogg" autoplay="true" hidden="true" loop="true" />
有任何想法吗?
解决方案
只需尝试使用 CSSdisplay
而不是hidden
属性隐藏音频标签:
<audio src="file/example.ogg" autoplay="true" loop="true" />
audio {
display: none;
}
注意:音频和视频标签只有在静音时才能自动播放。(因为用户隐私)
<audio src="file/example.ogg" autoplay="true" hidden="true" loop="true" muted="true" />
推荐阅读
- spring-boot - 不需要使用 jwt 进行身份验证的 URL
- python - 极性和主观上来自文本
- ios - sqlite3_step 在 iOS 12 中导致 EXC_BAD_INSTRUCTION 崩溃
- python - 将mongodb json数组元素提取成json python
- reactjs - 如何在搜索后点击特定成员的完整详细信息?
- javascript - 使用Jquery事件'hashchange'重新格式化url哈希时如何避免无限循环
- python - How to remove quotes when I dump to another file?
- plot - df.plot() 对齐辅助 y 轴从零开始
- javascript - 在 Laravel Mix 中使用dependOn
- vue.js - 语法错误:从“电子”导入 {app、protocol、BrowserWindow}