Stereonaut!

And now Apache2::EmbedMP3 for your songs collections!
~ Feb 2, 2009

with 12 comments

After I spent time working on Apache2::EmbedFLV, I thought it was a good idea to do the same for audio files, specifically MP3 files.

So now that you have your MP3 files on your web server and they are accessible to the world, you may want to show them with an embedded audio player. Well, Apache2::EmbedMP3 is exactly for you!

EmbedMP3 uses the fabulous WP Audio Player, a small, elegant, GPL Flash audio player, similarly to how Apache2::EmbedFLV uses Flowplayer. The interesting thing about EmbedMP3 is that you can display more interesting data on the template such as song name, artist, album, year and also lyrics, which was an interesting feature I added. In this fashion, it's very easy to just drop a whole bunch of files into a directory and all be served with the custom interface.

You have to instruct Apache2:

<Files ~ "\.mp3$">
       SetHandler modperl
       PerlSetVar wpaudioplayer /audio-player/player.swf
       PerlSetVar wpaudioplayer_js /audio-player/wpaudioplayer.js
       PerlResponseHandler Apache2::EmbedMP3
</Files>

And that's it. Take a look at the documentation to see how to point it to specific locations for WP Audio Player, template file, etc.

You can see the hack in action at http://dev.axiombox.com/~david/mp3. If it struggles a bit by buffering, it's because that's directly from my home Internet connection, so give it a small break :-) And, as I suggested the Radiohead video with EmbedFLV, I suggest now this Black Eyed Peas song, Like That, it's very catchy and I love it ;-)

Go get the code at the Git repo or at CPAN (once it's updated and published).

Written by David Moreno

February 2nd, 2009 at 3:01 pm

12 Responses to 'And now Apache2::EmbedMP3 for your songs collections!'

Subscribe to comments with RSS or TrackBack to 'And now Apache2::EmbedMP3 for your songs collections!'.

  1. Hmm, something seems wrong there.
    I initially tries the first song in the list (Beastie Boys) and then tried to follow your recommendation. Only problem is: The player played the Beastie Boys again (though the lyrics of the Black Eyed Peas song showed AFAICT). This was under Firefox (2) on Windows XP (sorry).

    Sven Mueller

    2 Feb 09 at 3:27 pm

  2. Haha, oh dear, you're totally right. Apparently, there's some kind of persistent variables being stick all over the place.

    I'll fix ASAP, thanks!

    David Moreno

    2 Feb 09 at 3:34 pm

  3. I’m still missing the point of embedding a Flash application for such ridiculous purposes.

    It is still possible to embed audio and video elements in webpages without Flash, you just need the totem or vlc mozilla plugin (or its WMP equivalent on Windows), and that’s enough. You get better performance, better reliability and a better user interface this way. Embedding a video in an embedded application is a step in the wrong direction; happily the tag will go in the other one.

    Np237

    2 Feb 09 at 3:52 pm

  4. Exactly, @Np237, you are missing completely the point.

    I like Flash because most of end users around the world have it installed and it reaches most of the audience, that's it. I'm pretty sure there are better technologies out there, because it makes more sense for a global audience and most people dig it.

    Ridiculous purpose? Well, this kind of things doesn't really have a purpose, other than showing that you can do some interesting hacks mixing a little bit of here and there. I didn't mean it to have a purpose per se, you are probably seeing way beyond the real scope of it.

    However, I should probably prevent some of my posts to appear on Debian Planet, or just narrow them to Debian-specific strictly, since it appears that it's simply not a place for them.

    Thanks for your comment, though.

    David Moreno

    2 Feb 09 at 4:10 pm

  5. @Sven:

    I've fixed the issue and committed the fix. Thanks for noticing!

    I will also upload the CPAN module updated soon.

    David Moreno

    2 Feb 09 at 4:25 pm

  6. Looks interesting. A few suggestions:

    * Please add a direct download link for the file, rather than forcing people to dig through the page source for it.

    * Please wrap the embedded player in an audio tag for use with current browsers, leaving the SWF as a fallback.

    Anonymous

    2 Feb 09 at 4:42 pm

  7. @Anonymous:

    Great suggestions! That's exactly the fine input that I'm really thankful of!

    Cheers.

    David Moreno

    2 Feb 09 at 4:47 pm

  8. Is this supposed to be “free”?

    However, for these who do not (want to) use any
    variant of Macrobe Flash, why does it not include
    a hyperlink pointing directly to the .mp3 (or .flv)
    file, so that people using Lynx as web browser can
    still use said content?

    mirabilos

    3 Feb 09 at 3:10 am

  9. What I’m saying is that other technologies also reach most of the audience, in a more accessible and more reliable way. I could list reasons why you shouldn’t use Flash when there are alternatives, but I’d probably hit the comment length limit.

    Using SWF as a fallback, as suggested by Anon, is on contrary a very good idea. I didn’t know this was possible and it sounds like the right thing to do.

    (FWIW I think this kind of post is perfectly appropriate on Planet – it’s related to free software and it’s technical, that’s more than many of the posts there.)

    Np237

    3 Feb 09 at 4:01 am

  10. @mirabilos:

    Yes, it's supposed to be free.

    For those who don't want to use any variant of Flash, well, they could wait for the proposed fallback or simply not use the product.

    Thanks for commenting.

    David Moreno

    3 Feb 09 at 10:54 am

  11. Hello webmaster
    I would like to share with you a link to your site
    write me here preonrelt@mail.ru

    Alexwebmaster

    3 Mar 09 at 6:10 am

  12. amazing stuff.

Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes