Thursday, April 06, 2006

XSPF MP3 Playlister

Ok, so here goes my first actual blog post! I'm posting a VBscript that allows you to create an XSPF playlist (i.e., an XML playlist of mp3's) just by dragging a folder onto the script. I rewrote the original script, an m3u generator, to output XSPF playlists.

Here's the script, followed by instructions on its use:

http://www.iol.ie/~craigcharlie/files/XSPF_Playlister.vbs
*Edited February 2008 - This link has been updated to point to version 2.0, which processes many file types in addition to Mp3s and includes many bug fixes. For more information see here.

The following instructions are tailored to Jeroen Wijering's fantastic Flash mp3 player, hence the references to mp3player.swf. However, the resulting playlist.xml file should be usable for any XSPF-capable player, e.g., the XSPF Web Music Player,and the macdaddy of all players, the cross-platform media swiss-army knife that is VLC.

  1. Move the .vbs file into the directory that contains the mp3 folder you want to playlist. This is necessary to preserve the relative paths that the player requires.
  2. Just drag n' drop the mp3 folder onto the .vbs file, and it will output a playlist.xml file in the same directory as the script.
  3. Now, make sure that the directory for your mp3player.swf file contains a exact copy of the mp3 folder you just dragged onto the .vbs.
  4. Then just copy the playlist.xml file into the folder that your mp3player.swf file is in. That's it! The next time you open the player it will have the updated songs, including a Google search link for each song name.

Features:

  • The script currently only processes mp3s. However, you could customize it to run on other file types by changing the value of the "sExtToGet" string.
  • The script does process subfolders.
  • Output is alphanumerically sorted, listing subfolders first, followed by files in the root directory.
  • Output is in UTF-8, and should be fine for most commonly used characters (stuff like "ç" and "ã" and "é" )
  • The script outputs relative paths.
  • Within the vbs file, you can customize the content of the tags if you'd like to provide a different link. You can also customize the title and of the playlist and put your webpage in the playlist info tag. Just search for the string "Your" to find these in the file.
Enjoy!

- Charlie

7 Comments:

At 7:12 PM, Blogger Fabricio said...

Hi Charlie, looks good! The xspf music player dont require any particular extension and should work with any file name, there is no need for ending with .xspf .xml or any other. Of course that the contents of this file must be a plain text utf well formated xml following the xspf specs...

If you has experienced problems please send me an email with the playlist file that you are having trouble opening and I will try to help.

[]s

 
At 10:25 AM, Blogger Sagacious Himself said...

ahh.. I have a better idea for ID3 naming: ReNamer
http://www.redbrick.dcu.ie/~den4b/

it'll use whatever naming convention is desired. in combination with your VBS its truly a fantastic solution!

 
At 2:42 PM, Blogger SaWey said...

Hi, is recently saw your thread on jeroenwijerings site,

I had a few suggestions to change your code:

If you have the CddbID3Tag.dll registered in your system32 folder, you can add id3 tags to the playlist:

in the AddFiles Sub, replace the first line with
Dim strExt, mpFiles, strName, foldName, foldPath, f, sulength, suname, leslash, ftitle
Dim id3: Set id3 = CreateObject("CDDBControl.CddbID3Tag")



then in the For each f in mpfiles:

strName = f.Name
id3.LoadFromFile f.Path, False
ftitle = id3.Title
If len(ftitle) <= 2 Then
ftitle = strName
End If


And as a last thing, change the arrFiles to put in the ftitle as title for the file and id3.LeadArtist for the author

This will give some nice ID3 tag support.

 
At 6:58 PM, Blogger Charlie Craig said...

Sounds good to me.. nice work! Sorry I only saw this now, had to knock the dust off this blog :)

 
At 1:13 AM, Anonymous zainal said...

thanks for the nice script, works perfectly.

 
At 11:06 PM, Anonymous Jerry B said...

Very impressive and thank you for sharing your work with us.

I need to generate a playlist with flv files so I tried to retrofit this by changing every instance of "mp3" to flv in the code. No luck. Player window opens with nothing to play. The list is generated and looks correct. Any suggestions?

 
At 11:27 AM, Blogger Charlie Craig said...

The quick answer is: the script was badly in need of an update.

I'll be posting a new one in the next few days that should work fine for you. There will be some bug fixes and some improvements, so stay tuned.

 

Post a Comment

<< Home