How to Autoplay Embedded YouTube Videos on Your Page?

YouTube makes it easy to embed videos on your website. By modifying the video’s parameters, you can control a variety of the embedded video’s settings, including enabling the autoplay feature to have the video start playing automatically as soon as a user lands on the page.

YouTube Embed Video
YouTube Embed Video

This guide will walk you through the process of setting a YouTube video to autoplay when it is embedded on a website. Importantly, using the autoplay feature for embedded videos does not contribute to the video’s view count.

  1. Visit the YouTube video you want to embed on your site.
  2. Below the video, click on the Share button.
    Opening YouTube Video Share Dialog Box
    Opening the YouTube Video Share Dialog Box
  3. Select the Embed feature.
    Navigating to Embed
    Navigating to Embed
  4. Copy the provided HTML code and paste it into your website’s code editor.
  5. Add the autoplay parameter to the src attribute in the video embed code.
  6. Locate the video ID within the code, and append the ?autoplay=1 parameter following it.
  7. Here is a comparison example for clarity:
    Before: 
    
    <iframe
      width="560"
      height="315"
      src="https://www.youtube.com/embed/BNuGMErEEIY"
      title="YouTube video player"
      frameborder="0"
      allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
      allowfullscreen
    ></iframe>
    
    After:
    
    <iframe
      width="560"
      height="315"
      src="https://www.youtube.com/embed/BNuGMErEEIY?autoplay=1"
      title="YouTube video player"
      frameborder="0"
      allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
      allowfullscreen
    ></iframe>
    
  8. If the embed code already includes a URL parameter—indicated by the ? symbol immediately following the video ID—you should use the & sign to append additional parameters. For example:
    Before: 
    
    <iframe
      width="560"
      height="315"
      src="https://www.youtube.com/embed/BNuGMErEEIY?si=vDPs7OZntRcR3XVs"
      title="YouTube video player"
      frameborder="0"
      allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
      allowfullscreen
    ></iframe>
    
    After: 
    
    <iframe
      width="560"
      height="315"
      src="https://www.youtube.com/embed/BNuGMErEEIY?si=vDPs7OZntRcR3XVs&autoplay=1"
      title="YouTube video player"
      frameborder="0"
      allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
      allowfullscreen
    ></iframe>

With this simple adjustment, you have the ability to decide if an embedded video should start playing automatically.

ABOUT THE AUTHOR

Kevin Arrows


Kevin Arrows is a highly experienced and knowledgeable technology specialist with over a decade of industry experience. He holds a Microsoft Certified Technology Specialist (MCTS) certification and has a deep passion for staying up-to-date on the latest tech developments. Kevin has written extensively on a wide range of tech-related topics, showcasing his expertise and knowledge in areas such as software development, cybersecurity, and cloud computing. His contributions to the tech field have been widely recognized and respected by his peers, and he is highly regarded for his ability to explain complex technical concepts in a clear and concise manner.