HTML Audio & Video
HTML DOM Audio defaultMuted Property
The defaultMuted property sets or returns whether a media element should be muted by default. It reflects the muted HTML attribute, which is different from the live muted property that reflects the element's current sound state.
Definition and Usage
There are two separate concepts of mute. The muted property is the current, live state and changes whenever the user or your code toggles sound. The defaultMuted property is the initial value, tied to the muted attribute, and is the state the element returns to when it is reset.
Syntax
// Get the value
let dm = mediaElement.defaultMuted;
// Set the value
mediaElement.defaultMuted = true;It is a boolean. Setting defaultMuted adds or removes the muted attribute in the markup, but it does not change whether the element is muted right now.
Example
<video id="myVideo" muted controls>
<source src="movie.mp4" type="video/mp4">
</video>
<script>
const video = document.getElementById("myVideo");
console.log(video.defaultMuted); // true (from muted attribute)
console.log(video.muted); // true (current state)
video.muted = false; // unmute live playback
console.log(video.defaultMuted); // still true (unchanged)
</script>As the example shows, unmuting live playback via the muted property leaves defaultMuted alone. This lets a page remember its intended default even after the user changes the sound.
To actually silence playback right now, set muted = true. Set defaultMuted only when you want to change the element's reflected muted attribute (its default/reset value).
