You can easily trigger a YouTube or Vimeo video to automatically play when a user lands on your site.
Before you add an autoplay video on your website, there are two things to keep in mind:
- The autoplay feature does not work on mobile or tablet devices.
- Most internet browsers will not allow the video to autoplay unless the video is muted first. The codes below will automatically mute the video for you.
For YouTube Videos:
- Navigate to the page where you would like to add your video, and create an HTML Block.
- Copy and paste the code below into the HTML block:
<iframe width="560" height="315" src="https://www.youtube.com/embed/TA-3Bsxabok?playlist=TA-3Bsxabok&autoplay=1&controls=0&loop=1&mute=1" frameborder="0" allowfullscreen></iframe>
- Once you have pasted the code above, you will want to replace two parts of the code (the parts that are bolded and underlined above) with your YouTube Video ID. You can find the Video ID by opening up your video directly on YouTube, then copying the information immediately following the v= in the URL (circled in screenshot below).
- Click the green Publish button to make your changes live.
For Vimeo Videos:
1. To modify the code to include an autoplay function, you will want to add this code to an HTML Block:
<iframe src="https://player.vimeo.com/video/305795958?background=1&autoplay=1&;title=0&;byline=0&;portrait=0&;loop=1&;autopause=0&;muted=1" width="640" height="360" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>
2. Replace the video ID in the code with the video ID from your Vimeo video. The video id is the number that immediately follows player.vimeo.com/video/ and ends before the ? symbol. In the above code, the video ID is the number 305795958. Replace that code with your video's ID.
3. Select the green Publish button to make your changes live.