In my project, there is a video gallery module. In this module, there are two options: direct FLV uploading, and adding a video embed code from YouTube.
I am writing some embed code for a div element (actually, the embed code comes from database). I want to make this video begin playing automatically.
<iframe title="YouTube video player" width="480" height="390" src="http://www.youtube.com/embed/zGPuazETKkI" frameborder="0" allowfullscreen></iframe>
This is a sample embed code from YouTube. I want to make this video play automatically using JavaScript.
YouTube Autoplay + Mute You can let your video start playing automatically when a user visits the page, by adding autoplay=1 to the YouTube URL. However, automatically starting a video is annoying for your visitors! Note: Chromium browsers do not allow autoplay in most cases. However, muted autoplay is always allowed.
Allowing iframes to autoplay video content You should also note the need to use the allowfullscreen attribute in complement to the allow attribute in order to support browsers that do not support allow attribute. If you are using amp-iframe and autoplay you need to add allow="autoplay" to your amp-iframe element.
AutoPlay may not work on YouTube due to corrupt cache/data of the browser or corrupt installation of the YouTube mobile application. Moreover, an outdated browser or misconfiguration of your browser like DRM settings, etc. may also cause the error under discussion.
You have to use
<iframe title="YouTube video player" width="480" height="390" src="http://www.youtube.com/embed/zGPuazETKkI?autoplay=1" frameborder="0" allowfullscreen></iframe>
?autoplay=1
and not
&autoplay=1
its the first URL param so its added with a ?
This works perfectly for me try this just put ?rel=0&autoplay=1 in the end of link
<iframe width="631" height="466" src="https://www.youtube.com/embed/UUdMixCYeTA?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With