[英]HTML Video mute button
我試圖在javascript中創建一個函數來使html視頻靜音,並將下面的圖標更改為我已下載的靜音圖標。 需要幫忙。 javascript也必須能夠與jquery一起使用
演示-http: //jsfiddle.net/victor_007/6cc9mhbb/
單擊該按鈕,圖標將更改
$("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'))
});
這個問題含糊不清,所以我猜這將回答您的問題。 如果您使用HTML中的視頻標簽
<video width="320" height="240" controls muted>
<source src="x" type="video/x">
<source src="x" type="x">
</video>
對於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>
至於您的第二個問題,我不太理解,請詳細說明。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.