简体   繁体   English

如何删除 HTML5 音频标签中的下载选项?

[英]How do I remove the download option in the HTML5 audio tag?

I am using the HTML5 audio tag on a website I'm maintaining.我在我维护的网站上使用 HTML5 音频标签。 I noticed that the audio tag has a download icon embedded in it.我注意到音频标签中嵌入了一个下载图标。 How do I remove that option?如何删除该选项? I want the audio to be read (playback) only.我只想读取(播放)音频。 Is there a way to do this without JavaScript or jQuery?有没有办法在没有 JavaScript 或 jQuery 的情况下做到这一点? I don't know either one yet.我一个都不认识。

To remove the download option from the UI add controlsList="nodownload" attribute要从 UI 中删除下载选项,请添加 controlsList="nodownload" 属性

        <audio
           controls
           controlsList="nodownload">

        </audio>

There is nothing on the audio element interface that controls only the download button. audio元素界面上没有任何东西只控制下载按钮。 There is the controls attribute, which is a Boolean attribute, just shows or hides all of the controls on the audio UI.controls属性,这是一个布尔属性,只是显示或隐藏音频 UI 上的所有控件。

Try this might it help you.试试这个可能对你有帮助。 It is not the best way but I think it will solve your problem.这不是最好的方法,但我认为它可以解决您的问题。

audio::-webkit-media-controls-enclosure {
    overflow:hidden;
}

audio::-webkit-media-controls-panel {
    width: calc(100% + 30px); /* Adjust as needed */
}

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

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