HTML DOM Video defaultMuted Property

HTMLWeb DevelopmentFront End Technology

<p style="">The HTML DOM Video defaultMuted property returns/sets boolean value corresponding to whether the video&rsquo;s audio will be on mute by default or not.</p><p style=""><strong>NOTE</strong> &minus; This property has no dynamic effect on HTML document but is just a reflection of the state of HTML DOM Video muted property.</p><h2 style="">Syntax</h2><p>Following is the syntax &minus;</p><p>Returning boolean value - true/false</p><pre class="result notranslate">mediaObject.defaultMuted</pre><p>Setting <strong>defaultMuted</strong> to booleanValue</p><pre class="result notranslate">mediaObject.defaultMuted = booleanValue</pre><p>Here, <strong>&ldquo;booleanValue&rdquo;</strong> can be the following &minus;</p><table class="table table-bordered"><thead><tr valign="TOP"><th>booleanValue<br></th><th>Details<br></th></tr></thead><tbody><tr valign="TOP"><td height="22" style="text-align: center;" width="147">true<br></td><td width="471">It definesthat video will have its audio on mute by default<br></td></tr><tr valign="TOP"><td height="22" style="text-align: center;" width="147">false<br></td><td width="471">It definesthat video will not have its audio on mute by default<br></td></tr></tbody></table><p>Let us see an example of <strong>Video defaultMuted</strong> property &minus;</p><h2 style="">Example</h2><pre class="demo-code notranslate language-html" data-lang="html">&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;HTML DOM Video defaultMuted&lt;/title&gt; &lt;style&gt; &nbsp; &nbsp;* { &nbsp; &nbsp; &nbsp; padding: 2px; &nbsp; &nbsp; &nbsp; margin:5px; &nbsp; &nbsp;} &nbsp; &nbsp;form { &nbsp; &nbsp; &nbsp; width:70%; &nbsp; &nbsp; &nbsp; margin: 0 auto; &nbsp; &nbsp; &nbsp; text-align: center; &nbsp; &nbsp;} &nbsp; &nbsp;input[type=&quot;button&quot;] { &nbsp; &nbsp; &nbsp; border-radius: 10px; &nbsp; &nbsp;} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &nbsp; &nbsp;&lt;form&gt; &nbsp; &nbsp; &nbsp; &lt;fieldset&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;legend&gt;HTML-DOM-Video-defaultMuted&lt;/legend&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;video id=&quot;demo&quot; width=&quot;320&quot; controls&gt;&lt;source &nbsp; &nbsp;src=&quot;http://www.tutorialspoint.com/html5/foo.mp4&quot; type=&quot;video/mp4&quot;&gt;&lt;/video&gt;&lt;br&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;input type=&quot;button&quot; onclick=&quot;getTrackDetails(1)&quot; value=&quot;Day Time&quot;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;input type=&quot;button&quot; onclick=&quot;getTrackDetails(2)&quot; value=&quot;Night Time&quot;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;div id=&quot;divDisplay&quot;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/div&gt; &nbsp; &nbsp; &nbsp; &lt;/fieldset&gt; &nbsp; &nbsp;&lt;/form&gt; &lt;script&gt; &nbsp; &nbsp;var divDisplay = document.getElementById(&quot;divDisplay&quot;); &nbsp; &nbsp;var demo = document.getElementById(&quot;demo&quot;); &nbsp; &nbsp;function getTrackDetails(val) { &nbsp; &nbsp; &nbsp; if(val == 1){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;demo.defaultMuted = false; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;divDisplay.textContent = &#39;Its day time!&#39;; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; else{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;demo.defaultMuted = true; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;divDisplay.textContent = &#39;Its night, so video will be on mute by default!&#39;; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp;} &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;</pre><h2>Output</h2><p>Clicking <strong>&lsquo;Night Time&rsquo;</strong> button &minus;</p><p><img src="https://www.tutorialspoint.com/assets/questions/media/30359/964.jpg" class="fr-fic fr-dib" width="600" height="316"></p><p>Clicking <strong>&lsquo;Day Time&rsquo;</strong> button &minus;</p><p><img src="https://www.tutorialspoint.com/assets/questions/media/30359/964_1.jpg" class="fr-fic fr-dib" width="600" height="340"></p>
raja
Updated on 21-Dec-2021 09:19:42

Advertisements