[英]Button to mute/unmute video bg on divi theme
I'm making a website for a client using the divi theme. 我正在使用divi主题为客户建立网站。 The site has a background video with sound.
该站点有带声音的背景视频。 The customer wants in the video a button to turn the sound on and off.
客户希望在视频中有一个按钮来打开和关闭声音。
With the following code I was able to mute but I can not make a button to turn on and off. 使用以下代码,我可以将其静音,但无法创建一个按钮来打开和关闭。
Can someone help me? 有人能帮我吗?
jQuery (document) .ready (function () {
jQuery (". et_pb_section_video_bg video"). prop ('muted', true);
});
Try with volume level! 尝试音量级别!
Edit 编辑
And here are the functions for some volume down/up buttons. 这里是一些音量调低/调高按钮的功能。
$(document).ready(function(){
// Video element
var myVideo = $(".et_pb_section_video_bg video")[0];
// On load state (muted)
myVideo.volume = 0;
$("#sound_up").on("click",function(){
var actual_volume = myVideo.volume;
if(actual_volume<1){
myVideo.volume += 0.2;
}
});
$("#sound_down").on("click",function(){
var actual_volume = myVideo.volume;
if(actual_volume>0){
myVideo.volume -= 0.2;
}
});
});
Assuming the et_pb_section_video_bg video
class is on the video element... 假设
et_pb_section_video_bg video
类在视频元素上...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.