Search code examples
videoyoutubeyoutube-api

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


I can't work out how to autoplay a video using the new embed code style for Youtube. I tried adding &autoplay=1 to the url, which worked with the old style, but it didn't work. For example, http://www.youtube.com/embed/JW5meKfy3fY is the embed link, but http://www.youtube.com/embed/JW5meKfy3fY&autoplay=1 doesn't work. Can anyone tell me how to do it? Thanks


Solution

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

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

    In case you wanna disable autoplay, just change from 1 to 0: ?autoplay=0.

    If you embed the Youtube video in an iframe, you need to add allow="autoplay" to the HTML. Example: <iframe src="https://www.youtube.com/embed/JW5meKfy3fY?autoplay=1" allow="autoplay"></iframe>