[英]HTML Video mute button
I have tried to create a function in javascript to mute a html video, and change the icon below to a mute icon that i have downloaded. 我试图在javascript中创建一个函数来使html视频静音,并将下面的图标更改为我已下载的静音图标。 Need Help.
需要帮忙。 The javascript has to be able to work along side jquery as well
javascript也必须能够与jquery一起使用
demo - http://jsfiddle.net/victor_007/6cc9mhbb/ 演示-http: //jsfiddle.net/victor_007/6cc9mhbb/
on click of the button the icon will change 单击该按钮,图标将更改
$("video").prop('muted', true);
$(".mute-video").click(function () {
if ($("video").prop('muted')) {
$("video").prop('muted', false);
$(this).addClass('unmute-video'); // changing icon for button
} else {
$("video").prop('muted', true);
$(this).removeClass('unmute-video'); // changing icon for button
}
console.log($("video").prop('muted'))
});
The question is fairly vague, so I'm guessing that this will answer your question. 这个问题含糊不清,所以我猜这将回答您的问题。 If you are using video tags in HTML
如果您使用HTML中的视频标签
<video width="320" height="240" controls muted>
<source src="x" type="video/x">
<source src="x" type="x">
</video>
For Java script 对于Java脚本
<video id="myVideo" width="x" height="x" controls>
....
</video>
<button onclick="enableMute()" type="button">Mute sound</button>
<script>
var vid = document.getElementById("myVideo");
function enableMute() {
vid.muted = true;
}
</script>
As for your second questions, I don't quite understand it, please elaborate. 至于您的第二个问题,我不太理解,请详细说明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.