HTML DOM Audio muted Property
The Audio muted property is used to set or return whether the audio output should be muted or not.
Syntax:
- It returns the muted property.
audioObject.muted
- It sets the muted property.
audioObject.muted = true|false
Property Values: This property accepts values true|false which is used to specify whether the audio output should be muted, or not. By default. it is false.
Returns: The Audio muted property returns a Boolean value true if the audio is muted, otherwise, it returns false.
The below program illustrates the Audio muted Property in HTML DOM:
Example: This example turns off the audio sound.
HTML
<!DOCTYPE html>
< html >
< head >
< title >
HTML DOM Audio muted Property
</ title >
</ head >
< body style = "text-align:center;" >
< h1 style = "color:green;" >
GeeksforGeeks
</ h1 >
< h2 style = "font-family: impact;" >
Audio muted Property
</ h2 >< br >
< audio id = "Test_Audio" controls>
< source src = "gfg.ogg" type = "audio/ogg" >
< source src = "gfg.mp3" type = "audio/mpeg" >
</ audio >
< p >
For muting the audio, double click
the "Enable Mute" button.
</ p >
< br >
< button ondblclick = "MyAudio()"
type = "button" >
Enable Mute
</ button >
< script >
let a =
document.getElementById("Test_Audio");
function MyAudio() {
a.muted = true;
alert(a.muted);
}
</ script >
</ body >
</ html >
|
Output:
Supported Browsers: The browsers supported by DOM Audio muted property are listed below:
- Google Chrome 1 and above
- Edge 12 and above
- Internet Explorer 9 and above
- Firefox 3.5 and above
- Apple Safari 3.1 and above
- Opera 12.1 and above
Last Updated :
22 Jun, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...