Recently, I had to look up how to make YouTube videos autoplay — I thought this might be beneficial to other people. There’s also other parameters you can add to embed codes to control the user experience if you want to experiment on your own.
A regular YouTube embed code looks something like this:
<iframe width="560" height="315" src="//www.youtube.com/embed/CcgvVt3QJUI" frameborder="0" allowfullscreen></iframe>
What we need to do is add a question mark to the end of that, to allow for parameters (options), and then we add the option to make the video autoplay.
You’ll need to add ?rel=0&autoplay=1 to the end of the embed URL. The rel is to control whether related videos play at the end or not. 0 indicates no, 1 indicates yes. The autoplay parameter controls whether the video autoplays in the same fashion — 0 for no, 1 for yes.
The finished embed code should look like the following:
<iframe width="560" height="315" src="//www.youtube.com/embed/CcgvVt3QJUI?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>
You can find the entire list of YouTube embed parameters on the Google Developers site. There is also a video below explaining how to change the embed code to make your videos autoplay once the page loads.