I am trying to embed the new iframe version of a YouTube video and get it to auto play.
As far as I can tell, there is no way of doing this by amending flags to the URL. Is there a way to do it by using javascript & the API?
I am trying to embed the new iframe version of a YouTube video and get it to auto play.
As far as I can tell, there is no way of doing this by amending flags to the URL. Is there a way to do it by using javascript & the API?
Multiple queries tip for those who don't know (past me and future me)
If you're making a single query with the url just
?autoplay=1
works as shown by mjhm's answerIf you're making multiple queries remember the first one begins with a
?
while the rest begin with a&
Say you want to turn off related videos but enable autoplay...
This works
and this works
But these won't work..
example comparisons
https://jsfiddle.net/Hastig/p4dpo5y4/
more info
Read NextLocal's reply below for more info about using multiple query strings
1 - add
&enablejsapi=1
toIFRAME SRC
2 - jQuery func:
Works fine
December 2018,
Looking for an AUTOPLAY, LOOP, MUTE youtube video for react.
Other answers didn't worked.
I found a solution with a library: react-youtube
Since April 2018, Google made some changes to the Autoplay Policy. So you will have to do something like this:
This works in Chrome but not Firefox 3.6 (warning: RickRoll video):
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.
To use javascript api,
To play the youtube with the id:
reference: https://developers.google.com/youtube/js_api_referencemagazine