Use HTML5 to Play Music

Posted on: May 30th, 2010 by Lab Ninja 4 Comments

Ah, codecs! What fun.

I didn’t really understand codecs until I started creating a video archive for Vuze downloads. At the time, I was building a home theater PC and quickly found that some of the various .mkv, mp4, and wav files would only play on specific players, like VLC for example.

So what does this have to do with web design? Well, the same principle applies when thinking about music only this time we (the designer, developer) is responsible for making the “browser” seamlessly support audio, regardless of which browser your visitors are using.

Ever wonder why you can’t play iTunes downloads on your MP3 player? It’s because they come encoded in some weird, proprietary format called ACC – which you can change by the way.

Flash has long been the standard for encoding video and audio files on the web, so much so, that it’s become somewhat of a standard. In fact, the debate as to whether we should use flash or HTML5 to support video and audio rages on still.

Recently, some big names dropped flash support in favor of HTML5 so if it’s good enough for Google and CNN, it’s good enough for me – and having never been a big fan of the Flash platform to begin with, I thought I’d dig in.

Alright then.

One of the first things to watch out for is which browser is going to support the HTML5 < audio > tag and furthermore which formats are supported by each browser. Currently, most modern browsers, including Mozilla’s FireFox (3.5+), Apple’s Safari (4+), and Google’s Chrome (3) all support the HTML5 standard for encoding those MP3 files but they seem to prefer different formats for encoding.

For example, FireFox has codecs that support OGG and WAV files while Chrome and Safari both support MP3. This makes our job a little more challenging because we want to make sure we have fall backs in place so that ANY browser, including the IE zombies, can listen to the audio file.

The website HTML5doctor.com has a great approach we’ll follow for getting this to work just right. Chris Coyier also has an example of how to set up a pretty slick WordPress customization for pulling the data (legally) and dynamically such that it pulls meta data information like album cover images, song titles, and artist.

Not only does Chris show us how to set this up, but he creates a custom field in the back end of WP so you can set it up and hand it off to a client with the full expectation that they will be able to manage their own music library.

We’re going to do both but first we will set up a quick HTML5 test to see which method we like best or if there’s some combination of both that works even better. Stay tuned!

4 Responses

  1. M to the P says:

    Great article, and I look forward to seeing where this aspect of development goes…. just wanted to mention that youtube is on the flash platform….going to be hard trump that giant…no matter who owns it.. thanks again and keep the articles coming!

  2. Chris says:

    YouTube has gone HTML5 — at least it’s available because you can now view pretty much EVERYTHING they have to offer on the iPhone in the normal Safari browser. I don’t even use the YouTube app anymore, just head over to youtube.com and viola! It also seems SUPER fast and sleek comparatively. So not only is it an alternative, it actually seems BETTER.

  3. Lab Ninja says:

    Hey Chris,
    Thanks for the heads up. I heard through the rumor mill that YouTube was moving to HTML5 but I wasn’t sure whether it had happened or not. Thanks for keeping us up-to-date and for commenting.

  4. Tula Towne says:

    Hello, I do not usually submit feedback on blogs, as I like to read only. However I discover the article that you’ve got written earlier has very insightful info, and I discover it very informational. Anyway, I am questioning whether or not you’re open for hyperlink exchange, as I hope that we are able to agree on a mutual link change agreement. Hope to listen to a positive reply from you, and have a fantastic day!

Leave a Reply