
How To Make A YouTube Video Embed Autoplay On Page Load
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="https://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.
Awesome man…
I always forget to save the code and always have to search for it. I just want to say thank you for helping me out.
I appreciate it..
Glad to be of service, Michael. Best of luck with your business.
How do you block YouTube on a school computer?
Hi Georgia:
This is something you would have to talk to your school’s IT department about. This may be difficult to accomplish, as there are several workarounds published online for the express purpose of getting around a YouTube block on school WiFi or computers.