Set YouTube Videos to Autoplay

A little while ago, browsers turned off videos that auto play. To be honest, I like that they did that because I didn’t like it when a page opened and a video started playing with the volume up. That resulted in some pretty embarrassing situations sometimes.

But, with internet marketing and on sales pages, it’s nice to have the videos going so there are situations when you do want the video to start playing (auto play). I found out that you can have videos auto play as long as the volume is down. This is great because if your video has text in it or captions on, people can start getting into the video without having to first start the video.

Here are the steps to setting embedded YouTube videos to auto play:

  1. Adjust your video’s embed code by adding “autoplay=1&mute=1” to it.
  2. Do this by either adding “?autoplay=1&mute=1” to the src variable or if you already have some variables there, then add “&autoplay=1&mute=1” instead (see the example below).

Here’s an example:

Here’s the YouTube embed code for one of my videos:

<iframe width="670" height="377" src="https://www.youtube-nocookie.com/embed/M8NcDDc4nkc" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Here’s the src (source) part of it:

src="https://www.youtube-nocookie.com/embed/M8NcDDc4nkc"

All you would do here is change it and add:

?autoplay=1&mute=1

So it looks like this:

src="https://www.youtube-nocookie.com/embed/M8NcDDc4nkc?autoplay=1&mute=1"

And you’re done. Here is the result:

<iframe width="670" height="377" src="https://www.youtube-nocookie.com/embed/M8NcDDc4nkc?rel=0&autoplay=1&mute=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Add the Code If You Already Have Variables

If you already have some variables there like the code you need to turn off suggested/related videos, like this:

src="https://www.youtube-nocookie.com/embed/M8NcDDc4nkc"

then you add:

?rel=0&autoplay=1&mute=1

So it looks like this:

src="https://www.youtube-nocookie.com/embed/M8NcDDc4nkc?rel=0&autoplay=1&mute=1"

And you’re done. Here is the result:

<iframe width="670" height="377" src="https://www.youtube-nocookie.com/embed/M8NcDDc4nkc?rel=0&autoplay=1&mute=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

This works because in the computer programming world, a 1 means “on” and a 0 means “off.” If the default value is off, then there’s no need to mention it. That’s why the variable isn’t there to begin with. For example, if you set autoplay to 0 and mute to 0, then there would be no change and it would not autoplay and it would not be muted.

So have fun with this. Again, it’ll work best on videos where you have text showing in the video. You can also turn captions on by default.

Turn YouTube Video Captions On by Default

To turn captions on as well, you’ll add this:

?cc_load_policy=1

or this if you have other variables already set:

&cc_load_policy=1

Just follow what I show above regarding where to add this and which of the two variables above to use.

The final result for me looks like this:

<iframe width="670" height="377" src="https://www.youtube-nocookie.com/embed/M8NcDDc4nkc?rel=0&autoplay=1&mute=1&cc_load_policy=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

You, of course need to add closed captions to your YouTube videos for this to work.

And You Can Loop the Playback, too!

To make the video continuously loop, use this:

?loop=1

or this:

&loop=1

Enjoy!

1 COMMENT

  1. If an option doesn’t exist to disable auto-play across your site, either the video containers will be added to an ad blocker or the site blocked completely. Outside of a result of a click intended to start a video, ie going to a YouTube link or an article labeled as a video, auto-play is never acceptable. If I did not provide explicit permission by intentionally acting to play a video either through a play button or a link labeled as a video than either a portion or the entirety of your site will be blocked, audio or no audio.

LEAVE A REPLY

Please enter your comment!
Please enter your name here