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?
at the end of the iframe src, add
&enablejsapi=1
to allow the js API to be used on the videoand then with jquery:
this should play the video automatically on document.ready
note, that you could also use this inside a click function to click on another element to start the video
More importantly, you cannot auto-start videos on a mobile device so users will always have to click on the video-player itself to start the video
Edit: I'm actually not 100% sure on document.ready the iframe will be ready, because YouTube could still be loading the video. I'm actually using this function inside a click function: