Turn off sound for a video:
document.getElementById("myVideo").muted = true;
<!DOCTYPE html> <html> <body> <video id="myVideo" width="100" height="100" controls> <source src="video.mp4" type="video/mp4"> <source src="video.ogg" type="video/ogg"> Your browser does not support the video tag. </video><br> <p id="demo"></p> <button onclick="enableMute()" type="button">Mute sound</button> <button onclick="disableMute()" type="button">Enable sound</button> <button onclick="checkMute()" type="button">Check muted status</button> <script> var x = document.getElementById("myVideo"); function enableMute() {//from w w w . ja v a 2 s . c om x.muted = true; } function disableMute() muted = false; } function checkMute() { document.getElementById("demo").innerHTML =x.muted; } </script> </body> </html>
The muted property sets or gets whether the audio output of the video should be muted.
This property mirrors the <video> muted attribute.
Property Values
Value | Description |
---|---|
true | Indicates that the sound should should be turned OFF for the video |
false | Default. Indicates that the sound should be turned ON for the video |
The muted property returns true if the audio output of the video is muted, otherwise it returns false.