Archive for March, 2009

Album Shuffle, a Random Playlist Generator

I first posted this on 18th February 2007 on my plain HTML site.

Something that has bothered me ever since I got my mp3 player was its inability to play whole albums in “random” order, rather than individual tracks. I’ve often found myself playing the same few albums over and over again and it takes a conscious effort to select something different. This program was the result. It was started as something that I might find useful, but ended up more as a programming exercise.

To solve this problem I’ve written a small application that lists the folders under a specified root, shuffles them and then writes out the files as a simple playlist. This playlist can then be copied to the mp3 player’s playlist folder, and there you go – a “randomised” playlist of albums. It requires the mp3 player to be connected to the PC (of course).

Random playlist Generator Screenshot

Random playlist Generator Screenshot

It’s not brilliant, but it does the job. I’m making it available online to download. I’m not charging for the software, but if you like it I’d appreciate a donation.


It was written in C# using Visual Studio 2008 on top of .NET 3.5 and is (obviously) only available for Windows. The list view and the previous and next buttons (< >) were put in for initial testing purposes, but being lazy I left them in when I got the rest of it working.

There are still things to do, like put in a better application icon, but my graphic design skills are virtually nonexistent so it’ll have to wait until I come across a better one on the web.

So I may well be updating it at some point (but don’t hold your breath) and I may even put the code online too (once I’ve tidied it up). The usual warnings and provisos apply to the program – use at your own risk, there’s no support etc. However, if you have any comments or suggestions then I’d be happy to hear from you.

On 6th March 2007 I made the first update as I found that I had got a duff folder somewhere in my music tree because the application failed with an IOException. The simplest solution was to put in a try...catch block around the offending code. This meant that it would ignore that folder and carry on with the rest of the tree.

On 13th September 2008 I updated the application again. While developing the random album chooser application I found a C# mp3 tag library (TagLib#) which has let me read the necessary information from the files (specifically the length of the track) to generate an m3u file.

On 25th October 2008 I uploaded version 2.0: The application is now multi-threaded. This means that you can now press Stop or hit Esc to cancel the shuffle – most useful if you’ve forgotten to set the search root correctly, which I usually do when running a new version for the first time. The application’s buttons are enabled or disabled appropriately when the state of the application changes.

I’ve recently been looking at Microsoft FxCop and reading up on .NET 3.5 and C# 3 so the code is now in a far tidier state than before. It hasn’t added any new functionality to the application so I haven’t updated the version number, but I have uploaded it as in installer rather than a zip file.

Future enhancements:

  • Look for music file types other than mp3.

© 2009, Chris. All rights reserved. If you republish this post can you please link back to the original post.

,

6 Comments