Reveal.js: All of YouTube videos embedded with autoplay=1 start simultaneously

Created on 7 Feb 2017  路  2Comments  路  Source: hakimel/reveal.js

I have 3 videos that I embed with <iframe>, they all have autoplay=1, since I wanted them to start as soon as the slide with that video is shown.

However instead all of them start playing at the same time (even before I see the slide with the first video).

question

Most helpful comment

You can remove the autoplay query from the YouTube URL and instead add a data-autoplay attribute on the iframe, like this:

<iframe src="https://www.youtube.com/embed/sGF6bOi1NfA" data-autoplay></iframe>

Alternatively, you can lazy-load the iframe when the containing slide is shown by swapping "src" for "data-src":

<iframe data-src="https://www.youtube.com/embed/sGF6bOi1NfA?autoplay=1"></iframe>

All 2 comments

You can remove the autoplay query from the YouTube URL and instead add a data-autoplay attribute on the iframe, like this:

<iframe src="https://www.youtube.com/embed/sGF6bOi1NfA" data-autoplay></iframe>

Alternatively, you can lazy-load the iframe when the containing slide is shown by swapping "src" for "data-src":

<iframe data-src="https://www.youtube.com/embed/sGF6bOi1NfA?autoplay=1"></iframe>

Thank you, I confirm this works!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gre picture gre  路  5Comments

ablakey picture ablakey  路  3Comments

justmytwospence picture justmytwospence  路  4Comments

AnnotatedJS picture AnnotatedJS  路  5Comments

karlroberts picture karlroberts  路  4Comments