Does the Youtube component in Webflow not work with CMS, or is there another way to autoplay videos in CMS?

Published on
September 22, 2023

The YouTube component in Webflow does not work with CMS directly. However, there is a workaround to autoplay videos in CMS using custom code. Here's how you can achieve it:

  1. Add a YouTube Embed element: Drag and drop a YouTube Embed element onto your CMS template or page.
  2. Set the video URL dynamically: Use the dynamic embed feature in Webflow to set the video URL dynamically from the CMS collection.
  3. Create custom code: In the page settings, head to the Custom Code tab and add the following code to the Footer Code section:
<script>function playVideo() {  var iframe = document.querySelector('.youtube-embed iframe');  var src = iframe.src;  iframe.src = src + '&autoplay=1';}</script>
  1. Add an interaction: Go to the Interaction panel and create a new interaction. Choose the trigger you prefer, such as page load or button click, and select the playVideo() function as the action.
  2. Apply the interaction: Apply the interaction to the YouTube Embed element.

By following these steps, you'll be able to autoplay YouTube videos in CMS content within your Webflow project. Keep in mind that this method uses custom code, so if you have limited experience with HTML, CSS, and JavaScript, it might be helpful to consult with a developer.

Additional Resources:

Q1: How do I add a YouTube video to my Webflow CMS template?
Q2: Can I autoplay Vimeo videos in Webflow CMS?
Q3: Is there a way to customize the YouTube video player controls in Webflow?