Autoplay on youtube embed (iframe) videos

I received a request from a customer few days ago, he wanted to have the youtube video he have on his website’s homepage to start playing automatically.
Of course, fisrt thing one thinks is that you just have to add the autoplay=1 at the end of the embed url, but… well you know that, it doesn’t work.

So after some googling and tests I found here ( the solution.


Just in case I am pasting here the same code you will find there:

You may want to remove functions 4, 5 and the event listener:

if you don’t want to stop the video to play after 6 seconds.

Posted in Code Tricks, Miscellaneous and tagged , , , .

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.