spiff with a silent X

I’ve been playing with XSPF, mostly so I can use the XSPF Web Music Player. There’s a Perl API for working with XSPF (XML::XSPF) which works well, but is extremely short on documentation.

Creating a playlist with XML::XSPF is pretty logical: create a new track object for each new track, then feed an array of these tracks into the playlist object. It took me a couple of hours of fiddling about (and much use of Data::Dumper::Simple, the plain man’s guide to tortuous data structures) to find that out.

The end result is this:
id32xspf – create XSPF playlist to stdout from a list of MP3s with ID3v2 tags.
It’s intended for use on a local directory of MP3s, which will subsequently be uploaded to a website. It uses MP3::Info to do the tag work.
It has some limitations:

  • every file must have ID3v2 tags.
  • it doesn’t handle file:// locations at all well, as their syntax is system-dependent. You’ll probably have to use the --urlbase option. For example, for Unix systems for local files in the current directory, I find -u file://`pwd`/ works well.
  • it doesn’t include track numbers, as I didn’t know that XSPF supported them.
  • it doesn’t create track artwork links, as this isn’t included in ID3 data.

One slightly amusing caveat about the XSPF Web Music Player is that it doesn’t understand the rate of some of lame‘s more amusing VBR presets. If you feed it files from the voice preset (56kbit, mono, resampled to 32000Hz), the results sound like Pinky & Perky

Leave a Reply

Your email address will not be published. Required fields are marked *