CMS Development

kdmeg
HubSpot Employee
HubSpot Employee

How do I get my YouTube video to autoplay when my page loads?

Grab the embed code from the YouTube video to be added to your page:

<iframe width="560" height="315" src="http://www.youtube.com/embed/evL5jaZx8vk" frameborder="0" allowfullscreen></iframe>

Add "?rel=0&autoplay=1" after the URL in the embed code src:

<iframe width="560" height="315" src="http://www.youtube.com/embed/evL5jaZx8vk?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>

0 Upvotes
8 Antworten
emildior
Mitglied

How do I get my YouTube video to autoplay when my page loads?

Since April 2018, Google made some changes to the Autoplay Policy. You not only need to add the autoplay=1 as a query param, but also add allow='autoplay' as an iframe's attribute

So while embed youtube video, you will have to do something like this:

<iframe src="https://www.youtube.com/embed/VIDEO_ID?autoplay=1" allow='autoplay'></iframe>

 

sidneyhaitoff
Teilnehmer/-in

How do I get my YouTube video to autoplay when my page loads?

And there's no option to unmute from mobile when the mute code is added to the embed code.

0 Upvotes
KKnowles
Mitglied

How do I get my YouTube video to autoplay when my page loads?

Old thread but still relevant as I hit this issue today. If you set &mute=1 in your embed code, autoplay will work as expected.

ALeonard
Mitwirkender/Mitwirkende | Elite Partner
Mitwirkender/Mitwirkende | Elite Partner

How do I get my YouTube video to autoplay when my page loads?

Thanks @KKnowles! Your comment is what helped solve my issue. 

The embed url that ended up working for me was src="https://www.youtube.com/embed/HCc0OUmmPd8?feature=oembed&amp;autoplay=1&amp;mute=1&amp;cc_load_polic..." which you can on our Content Marketing page. 

sidneyhaitoff
Teilnehmer/-in

How do I get my YouTube video to autoplay when my page loads?

Only on desktop, but it's not working for me on mobile for some reason.

0 Upvotes
toriworks
Teilnehmer/-in

How do I get my YouTube video to autoplay when my page loads?

How does this work though when using the Video module? (not an embed code)

0 Upvotes
ecamu
Mitglied

How do I get my YouTube video to autoplay when my page loads?

Ok - after some research and troubleshooting - I've discovered that Google has changed their autoplay policy in Chrome to "improve the user experience."  

 

https://developers.google.com/web/updates/2017/09/autoplay-policy-changes 

 

I don't like it. But  at least it still autoplays in Firefox and Edge/IE.

ecamu
Mitglied

How do I get my YouTube video to autoplay when my page loads?

This used to work beautifully but now it doesn't. Not on older landing pages or new one I make. Any ideas on what's wrong? Are there some new settings in Hubspot somewhere? I created a webpage on my website and used the same embed code and it worked perfectly.  But on Hubspot landing pages it will not autoplay. Help is greatly appreciated!

0 Upvotes