Zachary asks, “Once I have inserted a YouTube video into my website, is there any way to get it to play automatically? If so, how?”
If your website is created with a blogging tool like WordPress, adding a video is generally as simple as copying the video URL and pasting it into the page you are using to write the rest of the post. If you want to customize the way the video plays, like having it auto-start when the page loads, you need to use the embed code provided by YouTube as an iFrame in the “Custom HTML” content type. It also requires one additional step to make the YouTube video start playing automatically, which requires modifying the code provided by YouTube for posting.
The first part of adding a YouTube video to your web page is to open the embed code from the sharing options on the video page.
Next you need to copy the embed code and paste it into the software you use to create your web pages. In this case, I’ll screenshot what this looks like in WordPress.
The screen below shows the code selected in the previous step pasted into a Custom HTML block.
Now you need to make some changes to the code in order for the video to automatically start playing when the page loads. In the screen above you can see that the video URL is listed as: src=”https://www.youtube.com/embed/_aOQSN_Ahmo“
To make the video autoplay you need to change this from a video embed to a playlist embed like this: src=”https://www.youtube.com/embed?playlist=_aOQSN_Ahmo&autoplay=1“
Note that the ‘/’ is replaced by a ‘?’ and the playlist is the video ID from the orginal URL. The ‘&autoplay=1’ is added at the end so that the video will automatically play when the page loads.
Be careful in choosing to do this. Some people who visit your web page may be in a place where having a video start playing automatically could be very disruptive or even embarrassing depending on the video content. I strongly recommend against doing this with more than one video on the same page because configuring every video on a page to do this does result in them all starting at once.
You may also want to make your YouTube video repeat.