How To Autoplay Youtube Videos?

 

Sometimes you’ll want to autoplay Youtube videos, for example, if you have a video squeeze page (see mine here).

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, and that’s not hard! :)

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&amp;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&amp;hl=en_GB&amp;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&amp;hl=en_GB&amp;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&amp;hl=en_GB&amp;rel=0&amp;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&amp;hl=en_GB&amp;rel=0&amp;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!

.

{ 21 comments… add one }

  • Eddie May 2, 2011, 9:38 pm

    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.

    Reply
  • Melanie May 30, 2011, 12:16 am

    Hm doesn’t seem to work.

    Reply
    • John Lagoudakis May 30, 2011, 1:02 am

      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.

      Reply
  • Amber July 17, 2011, 7:18 am

    I can’t get it to work. Do you need my embed code?

    Reply
  • Facundo August 3, 2011, 1:46 pm

    Perfect, exactly the little piece of code I was looking for. Thanks

    Reply
  • Sabretooth Snaggle August 24, 2011, 10:13 am

    Works ‘like a boss’
    Will use this again as now you tube videos can autoplay its a whole new world. Nice one dude

    Reply
  • bob November 10, 2011, 10:01 pm

    Thanks for this sir! worked like a charm! looks like this tutorials’ much updated compared to youtube’s API.
    bob´s last blog post ..When the old comes new… again.

    Reply
  • Dave November 12, 2011, 12:04 am

    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

    Reply
  • Shahriat Hossain January 3, 2012, 5:52 pm

    Nice to see that such a helpful site and contents – Thanks!

    Reply
  • Hiba March 4, 2012, 2:34 am

    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!!!!!

    Reply
  • Helmin Husakovic March 12, 2012, 2:51 am

    Thanks, it’s work!

    Reply
  • Geoff June 16, 2012, 5:29 pm

    Thanks – done the job!
    Geoff

    Reply
  • Nico January 15, 2013, 1:17 am

    John..Many thanks for the new youtube embed code business yes

    Reply
  • Dario Petkovic February 25, 2013, 11:47 pm

    I still refer to this post to make my youtube videos to autoplay! Thanks John!

    Reply
  • Lantana July 15, 2013, 3:35 pm

    Does anybody know how to change video volume on site? John, please, help) *I’m russian and english isn’t my native language.

    Reply

Leave a Comment

CommentLuv badge