Can an audio player be added to Webflow without using a CMS collection and with a stop/start or pause button on each track?

Published on
September 22, 2023

Yes, it is possible to add an audio player to Webflow without using a CMS collection. Webflow provides the Audio element, which allows you to add audio files directly to your website.

To add an audio player with a stop/start or pause button on each track, you can follow these steps:

  1. Upload your audio files to your Webflow project. Go to the Assets panel in the Designer, click on the "Upload" button, and select your audio files.

  2. Drag and drop an Audio element onto your page. The Audio element can be found in the Elements panel.

  3. In the settings for the Audio element, you will find an "Upload audio file" field. Click on the field, and select the audio file you want to use for that specific track.

  4. To add a stop/start or pause button for each track, you can use custom code. Firstly, give each Audio element a unique ID by selecting it and going to the Elements panel, then clicking on the "Settings" tab and setting an ID in the "Element ID" field. Make sure each Audio element has a different ID.

  5. Next, go to the page settings by clicking on the "Pages" tab in the Designer, selecting the specific page, and clicking on the "Custom code" tab. Inside the <head> tags, insert the following code:

<script>  function playPause(id) {    var audio = document.getElementById(id);    if (audio.paused) {      audio.play();    } else {      audio.pause();    }  }</script>
  1. In the Designer, go back to the page and select the parent element that contains the audio player. In the Style panel, add a class to this parent element, for example, "audio-player".

  2. Add a button element for each track and give them a class, for example, "play-button". Set the onclick attribute to call the playPause() function and pass in the ID of the corresponding audio element. The code for each button should look like this:

<button class="play-button" onclick="playPause('audio-id')">Play/Pause</button>

Replace 'audio-id' with the unique ID of the corresponding audio element.

  1. Finally, go to the page settings, click on the "Custom code" tab, and inside the <head> tags, insert the following code to style the play buttons:
<style>  .play-button {    background-color: #000;    color: #fff;    padding: 10px 20px;    border: none;    cursor: pointer;  }</style>

Customize the CSS styles as per your design preferences.

That's it! You now have an audio player with stop/start or pause buttons for each track on your Webflow website, without using a CMS collection.

Additional Questions:

  1. How can I add an audio player to Webflow without using a CMS collection?
  2. Is it possible to have stop/start or pause buttons on each track in a Webflow audio player?
  3. What are the steps to add a customized audio player in Webflow without using a CMS?