Audio muted Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Audio

Description

The muted property sets or gets whether the audio should be sound turned off.

This property reflects the <audio> muted attribute.

Set the muted property with the following Values

Value Description
true|false Sets whether the audio output should be muted
  • true - sound should be turned OFF
  • false - Default. sound should be turned ON

Return Value

A Boolean, returns true if the audio output is muted, otherwise it returns false

The following code shows how to Turn off sound:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<audio id="myAudio" controls muted>
  <source src="your.ogg" type="audio/ogg">
  <source src="your.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio><br>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from  w ww . j  av a 2 s .c  om*/
    document.getElementById("myAudio").muted = true;
}
</script>

</body>
</html>

Related Tutorials