我正在维护的网站上使用HTML5 audio标签。我注意到audio标签中嵌入了一个下载图标。如何删除该选项?我希望仅读取(播放)音频。是否有方法在不使用JavaScript或jQuery的情况下做到这一点?我还不知道这两种方法。
unhi4e5o1#
要从UI中删除下载选项,请添加controlsList=“nodownload”属性
<audio controls controlsList="nodownload"> </audio>
<audio
controls
controlsList="nodownload">
</audio>
字符串
zysjyyx42#
试试这个可能对你有帮助。这不是最好的方法,但我认为它会解决你的问题。
audio::-webkit-media-controls-enclosure { overflow:hidden;}audio::-webkit-media-controls-panel { width: calc(100% + 30px); /* Adjust as needed */}
audio::-webkit-media-controls-enclosure {
overflow:hidden;
}
audio::-webkit-media-controls-panel {
width: calc(100% + 30px); /* Adjust as needed */
bgibtngc3#
audio元素界面上没有任何东西只控制下载按钮。有controls属性,这是一个布尔属性,只是显示或隐藏音频UI上的所有控件。
audio
b09cbbtk4#
这是我用来获得所需结果的函数。希望它能帮助你.
function disable_audio_download() {?><script> document.querySelectorAll('.wp-block-audio audio').forEach(function(audio) { audio.setAttribute('controlsList', 'nodownload'); });</script><?php
function disable_audio_download() {
?>
<script>
document.querySelectorAll('.wp-block-audio audio').forEach(function(audio) {
audio.setAttribute('controlsList', 'nodownload');
});
</script>
<?php
字符串} add_action('wp_footer','disable_audio_download');
klsxnrf15#
只需将controlsList="nodownload"添加到controls的正上方,如下所示:
controlsList="nodownload"
<audio id="audio-element" controlsList="nodownload" controls className="w-full rounded-lg p-2 bg-gray-200 border border-gray-400" > <source src={`http://localhost:3000/api/audiobook/stream/${audioBook?._id}`} type="audio/mpeg" /> Your browser does not support the audio element. </audio>
id="audio-element"
className="w-full rounded-lg p-2 bg-gray-200 border border-gray-400"
>
<source
src={`http://localhost:3000/api/audiobook/stream/${audioBook?._id}`}
type="audio/mpeg"
/>
Your browser does not support the audio element.
5条答案
按热度按时间unhi4e5o1#
要从UI中删除下载选项,请添加controlsList=“nodownload”属性
字符串
zysjyyx42#
试试这个可能对你有帮助。这不是最好的方法,但我认为它会解决你的问题。
字符串
bgibtngc3#
audio
元素界面上没有任何东西只控制下载按钮。有controls
属性,这是一个布尔属性,只是显示或隐藏音频UI上的所有控件。b09cbbtk4#
这是我用来获得所需结果的函数。希望它能帮助你.
字符串
} add_action('wp_footer','disable_audio_download');
klsxnrf15#
只需将
controlsList="nodownload"
添加到controls
的正上方,如下所示:字符串