To embed a YouTube video and make it auto-play on your blog post, follow these steps:
1. Get the Embed Code from YouTube
- Go to the YouTube video you want to embed.
- Click on the “Share” button below the video.
- Select “Embed.”
- Copy the iframe code provided.
2. Modify the Embed Code for Autoplay
To make the video autoplay, you need to modify the embed code slightly. Here’s an example:
Original YouTube embed code:
<iframe width=”560″ height=”315″ src=”https://www.youtube.com/embed/VIDEO_ID” frameborder=”0″ allowfullscreen></iframe>
Modified embed code with autoplay:
<iframe width=”560″ height=”315″ src=”https://www.youtube.com/embed/VIDEO_ID?autoplay=1″ frameborder=”0″ allow=”autoplay; encrypted-media” allowfullscreen></iframe>
- Replace
VIDEO_ID
with the actual video’s ID (which can be found in the URL of the YouTube video). - The
?autoplay=1
parameter tells the video to start playing automatically.
3. Paste the Code into Your Blog Post
- If you are using a blogging platform like WordPress or Blogger, go to the HTML editor mode of your post.
- Paste the modified embed code where you want the video to appear.
4. Additional Considerations
- Some browsers may block autoplay depending on user settings or device type.
- Be cautious with autoplay, as it may disrupt the user experience, especially for mobile users or those with limited bandwidth.
That’s it! Now your YouTube video will automatically play when someone opens your blog post.