How to Embed an Autoplaying Youtube Video in an Iframe

How to embed an autoplaying YouTube video in an iframe?

This works in Chrome but not Firefox 3.6 (warning: RickRoll video):

<iframe width="420" height="345" src="http://www.youtube.com/embed/oHg5SJYRHA0?autoplay=1" frameborder="0" allowfullscreen></iframe>

The JavaScript API for iframe embeds exists, but is still posted as an experimental feature.

UPDATE: The iframe API is now fully supported and "Creating YT.Player objects - Example 2" shows how to set "autoplay" in JavaScript.

Embedded YouTube iframes No Longer Autoplay

Major browser have disabled these features due to general abuse.

https://developers.google.com/web/updates/2017/09/autoplay-policy-changes

https://blog.mozilla.org/firefox/block-autoplay/

YouTube checks upon loading whether it has permission to play how it wants to play the video. It will only autoplay if it has proper permission. The default in recent Chrome and Firefox builds is to only allow video - no sound. Adding &mute=1 the the youtube URL allows (muted) autoplay. This works if you don't necessarily need the sound, if you do then you will have to make the user click play themselves.

Applying this to the embed in your example:

<iframe allow="autoplay" frameborder="0" allowfullscreen="" src="https://www.youtube.com/embed/sapLz6NjvJk?autoplay=1&mute=1&origin=https://OurWebsiteDomain" title="Bug Week " height="278" data-ytbridge="vidSurrogate2" style="width: 100%;"></iframe>

How can I autoplay a video using the new embed code style for Youtube?

Just put "?autoplay=1" in the url the video will autoload.

So your url would be:
http://www.youtube.com/embed/JW5meKfy3fY?autoplay=1

In case you wanna disable autoplay, just make 1 to 0 as
?autoplay=0

Youtube embedded video autoplay

It's the browser blocking autoplay(with sound) by default.

https://developers.google.com/web/updates/2017/09/autoplay-policy-changes

It was finally implemented a few months ago. You can still use autoplay, but the video will need to be muted.

Notice the added mute=1 in the embed below. It will autoplay, but it breaks if you remove it.

<iframe width="560" height="315" src="https://www.youtube.com/embed/nwe76N7J0EI?rel=0&autoplay=1&mute=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

Why isn't my YouTube link autoplaying within an iframe in Chrome?

As mentioned in the comments, most modern browsers block autoplay videos these days unless they are muted. Just change your iFrame code to this