Navigation

How to use HTML5 audio (part 2)

By Sam Piggott | How To, HTML, Web Design | Apr 29, 2013

This is part two of the HTML5 audio introduction video; if you haven’t watched it already, I recommend checking out part one to get up to speed!

Today, we’ll be working on our HTML5 audio player and adding some exciting functionality to really bring our HTML5 player to life. We’ll be using a method involving data attributes, which allow for easy access to custom values for each audio element, and that’s where our titles, artists and album art come in.

By the end of this tutorial, you’ll understand the following: “Tagging” your audio elements with custom data attributes; such as track title, artist and even album art; using jQuery to manipulate this information and display it on the page, with the flexibility to style it around your own designs.

I’ll also be demonstrating my player example, and talking through how to accomplish certain effects with your data; including displaying the album art as a glossy backdrop to your player.

 

Have you featured HTML5 audio in a project? How does HTML5 audio compare with older options? Let us know your thoughts in the comments.

Featured image/thumbnail, sound image via Shutterstock.

Share this post
Comments (no login required)
  • http://www.eukhost.com/ eUKhost

    I will definitely use this to make things more advanced with my work. Nice update thank you so much for sharing.

  • Sami Mansour

    Firstly, I like to thank you on the lessons.
    I added previous button:
    $(‘.prev’).on(‘click’, function(){
    $.each($(‘audio.playsong’), function(){this.pause();});
    –i;
    nowPlaying[i].load();
    nowPlaying[i].play();
    callMeta();
    });

    After that I noticed if you click on next more than songs count you need to click on prev button the same you clicked on next button to play a song.

    I Solved this issue with define files count and add if statement in prev, and next buttons.

    as the attached image. :)

    Best regards,

    Sami Mansour

  • Anthony

    I would like to see the volume control coding aspect of the audio. Thanks for the video and instructions.