Learn to Build an Audio Player Using HTML5

Audio Player

Audio Player

In this article, we are going to build an audio player using HTML5. We are going to incorporate HTML5 audio features as well as JavaScript and jQuery. We will add features like Play, Previous, Next, Pause, Stop and Volume control. We will also include a progress-bar with time, as well as create a playlist of the songs added.

Steps for creating Audio Player UI – HTML

  • We are going to create a folder named “audio_player” and inside we are going to create the following structure:
  • Inside the “CSS” folder, we will create a “style.css” file. Similarly, In the “JS” folder we will add a “main.js” file. Please have a look at the screen-shot below.
    JS Folder
  • After that, go to jquery.com and download the “jquery” file. So, your folder structure should look like this.
  • Inside the “Media” folder, you can see the song list. I’ve attached the screen-shot below for reference:
  • Inside the “Image” folder, you can find the images and in the “cover” folder, you can find out the cover image of the album. I’ve attached the screen shot below:
    Cover Folder
  • Now, its time to design your front page. Open the index.html page and add the following code.


Steps for creating Audio Player UI – CSS

  • Now we are going to add the css code in our “style.css” file. For that, open your css folder and inside that you will see your style.css file. Open that file and add the following code:


Steps for creating Play, Pause & Stop buttons:

  • Now, we are going to add three buttons to our application using JavaScript for which you will need to go to your js folder and open the main.js file and add the following code:


  • Now we are going to add code for volume control and time duration in your main.js file. I had attached the code:

  • After that is done, we are going to add the Playlist functionality code. So, your final main.js should look like:

  • After we are finished with the coding, our application should look like this:


I hope this has been helpful for you guys in understanding a how to create Audio Player Application using HTML5 Goodluck!


  1. how can i implement a play all button using this ?
    var currentSong = 0;
    $(‘#playall’).click(function () {
    currentSong = $(‘#playlist li’).index()

    audio.addEventListener(‘ended’, function () {
    if (currentSong == $(‘#playlist li’).length) {
    currentSong = 0;
    var nextsong = $($(“#playlist li”)[currentSong])


    I tried to do this but it only play the next song, after that, it doesn’t play the third


Please enter your comment!
Please enter your name here