How to use autoplay and mute attribute with < video > tag in HTML for youtube ? with example

 How to use autoplay and mute attribute with < video > tag in HTML for youtube ? with example 


When you add or use autoplay attribute for your website development by adding value autoplay=1 to the YouTube URL.then video is automatically started when any unknown or unique visitor are visiting in your website . However, automatically starting a video is annoying for your visitors


<html>

<body>

<iframe width="420" height="315"

src="https://www.youtube.com/embed/tgbNymZ7vqY?

autoplay=1&mute=1">

</iframe>

</body>

</html>


When you apply both attribute with YouTube URL then Here is the effect after giving value to both of the attribute mute and Autoplay .

Add mute=1 after autoplay=1 to let your video start playing automatically (but muted).


Example 

<iframe width="560" height="315"

 src="https://www.youtube.com/embed/2jg1bJQaYjg"

autoplay=1 & mute=1 " 

title="YouTube video player" frameborder="0" 

allow="accelerometer; clipboard-write; encrypted-media; 

gyroscope; picture-in-picture" allowfullscreen></iframe>

Comments