“视频静音”属性用于设置或返回是否应将视频的音频输出静音。
用法:
要返回静音属性:videoObject.muted
要设置静音属性:videoObject.muted = true|false
属性值:
true | false:它用于指定是否应将视频的音频输出静音。
返回:如果视频的音频输出被静音,则“视频静音”属性将返回布尔值true,否则返回false。
以下示例程序旨在说明视频静音属性:
例:关闭视频的声音。
HTML | DOM Video muted Property
h1 {
color:green;
}
h2 {
font-family:Impact;
}
body {
text-align:center;
}
GeeksforGeeks
Video muted Property
width="360"
height="240"
controls>
type="video/mp4">
type="video/ogg">
For muting the videos, double
click the "Enable Mute" button.
For returning the mute status of the
video, double click the "Return Mute
Status" button.
type="button">
Enable Mute
type="button">
Return Mute Status
var v = document.getElementById(
"Test_Video");
function set() {
v.muted = true;
}
function get() {
alert(v.muted);
}
输出:
原来:
启用静音之前:
启用静音后:
支持的浏览器:HTML | DOM视频静音属性如下所示:
谷歌浏览器
IE浏览器
Firefox
Opera
苹果Safari