3

I'd like for a YouTube video to start playing right away with the sound muted when a user opens my webpage, but when embedding it from YouTube the user has to click on it and click "play" in order for the video to start playing.

Right now I get a code like this from YouTube:

<iframe width="560" height="315" src="https://www.youtube.com/embed/M0NXSdLlaZ4" frameborder="0" allowfullscreen></iframe>

And I'm not sure how to get the YouTube video to start playing as soon as the user opens the website.

daniel metlitski
  • 747
  • 3
  • 11
  • 23

1 Answers1

1

Check this answer:

How to make an embedded Youtube video automatically start playing?

It says to add ?autoplay=1 like this:

<iframe width="560" height="315" src="https://www.youtube.com/embed/M0NXSdLlaZ4?autoplay=1" frameborder="0" allowfullscreen></iframe>
User005
  • 66
  • 7
  • she works!!! does it always get started with the sound off? (i want to make sure the video doesnt start with sound on so as not to surprise my users) – daniel metlitski May 24 '17 at 12:21
  • You can add an **id** to the `` **The javascript code:** `var myVideo = iframe.getElementById('myvideo'); myVideo.mute();` Hope it helps you, – User005 May 24 '17 at 12:42