简体   繁体   English

如何在视频背景上添加静音/取消静音按钮[在Divi-WordPress]

[英]How to add Mute/Unmute Button on a Video Background [On Divi - WordPress]

How can I place a Mute/Unmute Button on a video background (MP4)? 如何在视频背景(MP4)上放置“静音/取消静音”按钮?

Website Link: http://bsibasketball.com/ 网站链接: http : //bsibasketball.com/

Any help would be appreciated. 任何帮助,将不胜感激。

Thank You So Much! 非常感谢!

Try it with this script: 使用以下脚本尝试:

 const btn = document.getElementById('mute'), video = document.querySelector('video'); btn.addEventListener('click', () => { if (btn.value === 'unmuted') { btn.value = 'muted'; btn.innerHTML = 'Unmute'; video.muted = true; } else { btn.value = 'unmuted'; btn.innerHTML = 'Mute'; video.muted = false; } }); 
 <video id="myVideo" autoplay> <source src="https://www.w3schools.com/jsref/movie.mp4" type="video/mp4"> <source src="https://www.w3schools.com/jsref/movie.ogg" type="video/ogg"> Your browser does not support the video tag. </video> <br> <button id="mute" value="unmuted">Mute</button> 

You are free to use it however you want. 您可以随意使用它。 You could also make the user to click on the video instead of a button. 您还可以使用户单击视频而不是按钮。

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

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