Important Notice – 1st February 2020: Youtube no longer offers the autoplay feature for embedded videos. This post is now outdated and the methods described below no longer work.
Sometimes you’ll want to autoplay Youtube videos, for example, if you have a video squeeze page.
By default, Youtube videos do not autoplay. But the good news is that autoplaying Youtube videos is very easy. All you need to do is add one line of code:
autoplay=1
The hardest part is knowing how and where to add it, but it’s not that difficult! 🙂
New Youtube Embed Code (default)
To get the Youtube embed code, you simply go to the video you want to embed on your website and click on the ‘Embed’ button (located below the video). You’ll be shown some code that looks like this:
<iframe title=”YouTube video player” width=”640″ height=”390″ src=”http://www.youtube.com/embed/s3DcPo3e5H0?rel=0″ frameborder=”0″ allowfullscreen></iframe>
Here’s where you can add the autoplay code:
<iframe title=”YouTube video player” width=”640″ height=”390″ src=”http://www.youtube.com/embed/s3DcPo3e5H0?rel=0&autoplay=1” frameborder=”0″ allowfullscreen></iframe>
Old Youtube Embed Code
If you’re using the old Youtube embed code, the original code will look like this:
<object width=”640″ height=”390″><param name=”movie” value=”http://www.youtube.com/v/s3DcPo3e5H0?fs=1&hl=en_GB&rel=0″></param><param name=”allowFullScreen” value=”true”></param><param name=”allowscriptaccess” value=”always”></param><embed src=”http://www.youtube.com/v/s3DcPo3e5H0?fs=1&hl=en_GB&rel=0″ type=”application/x-shockwave-flash” allowscriptaccess=”always” allowfullscreen=”true” width=”640″ height=”390″></embed></object>
Here’s where you’ll need to add the Youtube autoplay code (2 places):
<object width=”640″ height=”390″><param name=”movie” value=”http://www.youtube.com/v/s3DcPo3e5H0?fs=1&hl=en_GB&rel=0&autoplay=1“></param><param name=”allowFullScreen” value=”true”></param><param name=”allowscriptaccess” value=”always”></param><embed src=”http://www.youtube.com/v/s3DcPo3e5H0?fs=1&hl=en_GB&rel=0&autoplay=1” type=”application/x-shockwave-flash” allowscriptaccess=”always” allowfullscreen=”true” width=”640″ height=”390″></embed></object>
If you’ve found this article helpful, please leave a comment below. Thanks!
.
Do you know a line of code to add color to the play bar? They used to be able to come in all sorts of colors, blue, green, red, etc.
Hi Eddie, thanks for asking! I’ve used to have a step-by-step tutorial on how to do this also, but I took it down as that feature is no longer available.
Hm doesn’t seem to work.
Hi Melanie, please send me a copy of your embed code and I’ll take a look at it. Use the Contact form here. Thanks.
I can’t get it to work. Do you need my embed code?
Sure Amber. Send it through the form here: http://johnlagoudakis.com/contact Thanks
Perfect, exactly the little piece of code I was looking for. Thanks
Works ‘like a boss’
Will use this again as now you tube videos can autoplay its a whole new world. Nice one dude
Glad to hear it! Thanks for the feedback.
Thanks for this sir! worked like a charm! looks like this tutorials’ much updated compared to youtube’s API.
You might find this useful … created a script that allows you to select which Youtube embed parameters to include.
http://www.davewooding.com/how-to-customize-and-embed-a-youtube-video/
Thanks.
Dave
Well done Dave! Very handy script.
Nice to see that such a helpful site and contents – Thanks!
Thanks Shahriat!
Hi,
I’ve been having trouble embeding youtube players for the past 6 months…I used to be able to embed them just fine along with the autoplay thing but I don’t know why the embeding stopped working with either of the codes (old vs. new).
I have a feeling that the new code might not work on the website I’m trying to embed videos on (the website is http://www.viki.com) just because I don’t know whether the iframe thing works for them.
But I know that youtube embeding does work because I’ve seen other people embed the videos on their viki profiles, and even on comments.
I’ve had to resort to using mixpod.com but it doesn’t play all the videos I want.
Anyway for now I’d just like help with embeding this playlist >
http://www.youtube.com/playlist?list=PL6E27736F70E133B2
PLEASE HELP!!!!!
Thanks, it’s work!
Thanks – done the job!
Geoff
John..Many thanks for the new youtube embed code business yes
I still refer to this post to make my youtube videos to autoplay! Thanks John!
😉
Does anybody know how to change video volume on site? John, please, help) *I’m russian and english isn’t my native language.
Hi Lantana, sorry, don’t know how to do that one.
This does not really work , auto play stopped
Thanks Deb. This is an old article… I may need to update it.