Embedding a youtube video as a web object - I cannot get the video to autoplay

May 22, 2020

As per the title I've tried changing the auto play to autoplay=1 and other different things but I cannot for the life of me get it to work.

 

I want it to stop at 176 seconds

Code below:

<iframe width="560" height="315" src="https://www.youtube.com/embed/VinOp8dYbhA?controls=0&amp;start=0&end=176" frameborder="0" allow="accelerometer; autoplay=1; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>

 

Also I would like not to show the recommended videos at the end if possible

 

2 Replies
Andy Banga

Hi Andrew,

Good day!

The issue with autoplay is usually more on the browser’s autoplay settings or policy rather than the actual code. For instance, Chrome changed its policies to disable autoplay when there is no user interaction on the page. Storyline was able to create a workaround but this is only for non-embedded videos.

For your embed code, I’ve made some minor changes to stop the video playing after 176 seconds and to make it autoplay (only if the browser allows it). I would recommend testing in Firefox as it easier to enable the autoplay setting on this browser.

<iframe width="560" height="315" src="https://www.youtube.com/embed/VinOp8dYbhA?controls=0&amp;end=176&amp;autoplay=1" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>

As for disabling recommended videos or end cards, this is currently not possible through any API parameters or settings. You may get further insights from the YouTube API team and community. I hope this helps.

kevin katler

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>