Archive for category Mp3

Random Album Chooser

I first posted this on 14th September 2008 on my HTML site.

I’m now listening to more of my music on my PC but unfortunately my player of choice, MediaMonkey, doesn’t have an “album shuffle” mode. So I wrote myself a program to randomly pick an album and then pass the files to MediaMonkey to play. As usual the basics of the program were written quite quickly, it’s all the associated error checking, configuration and general prettifying (though some would debate that!) that take up the time. Why I’m still amazed by this after more than 25 years in the software development business I don’t know – eternal optimism perhaps – but there you go.

Anyway to get back to the business at hand, to use this program your music library must be organised at least by album and ideally by artist and album. Fire up the program and point it at your music library and tell it the location of your media player by selecting the settings button [Settings icon] and browsing to the relevant folder and file. The configuration dialog also allows you to specify the filenames to look for in the album’s folder if the cover image isn’t embedded in the mp3 files. I’ve added what I think are the most common names for folder art – well they’re the ones I’ve come across the most. I’ve allowed new names to be entered and the existing ones reordered to produce the optimum search for any situation. The program also looks for images named the same as the folder and album tag for good measure.

Random album chooser initial screen

Random album chooser initial screen

Random album chooser configuration dialog

Random album chooser configuration dialog

Having set up the system, click the shuffle button shuffle button. The program goes away and picks an album. Once it’s found one it displays both the album folder and its parent under the assumption that you’ve got your collection organised by artist. It also displays the album cover like this:

Random album Chooser results

Random album Chooser results

Why? I hear you ask. Well partly it’s a visual check that this is the album you want to play, but mainly because I could! Wanting to do it made me look for (and find) a C# tag reading library which I’d failed to find when writing my playlist generator.

When you’ve been presented with an album you want to hear simply click the album cover image. This will launch your media player of choice and start playing the album at track 1 – assuming you’ve named your files <Track#>-<Title>.mp3, as the files will be added in alphabetical order. I’ve tested it with Media Monkey, Winamp and Windows Media Player, so I’m confident it’ll work with any music player that accepts a list of files on its command line.

It’s not brilliant, but it does the job. And 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 C# Express 2005 on top of .NET 3 and is (obviously) only available for Windows. It uses a C# mp3 tag library (TagLib#) to pull out the cover art (assuming that it exists of course), and the additional information displayed when you right click over the cover image.

There’s an issue where I can’t locate cover images that aren’t embedded in the mp3 file but are referenced by name and that name is different to both the folder name and the value of the album name tag. The relationship between the mp3 and the image is set up in the file, but I can’t get at it. The code that looks for an image in the same folder gets round this in some cases – if it’s one of the filenames set up in the config file or its name is the same as the folder or album. I’ve contacted the developer of the library in case there’s something I’m missing, but I’ve not heard anything back. It doesn’t affect my use of the application as I’ve embedded the album art in all (well nearly all) my mp3s, but the completist in me wants to have this bit working too.

There’s been one benefit for me in using this – I’ve found a number of albums in my collection that haven’t had the album art assigned correctly. Usually it’s been tagged as something other than the front cover, but in a couple of cases it’s been missing altogether.

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 21st September 2008 I found that I’d set up the media player file open dialog incorrectly – causing the application to crash. Totally stupid mistake to make & I’m annoyed I didn’t spot it earlier. As I had to upload a fixed version I’m released extra options to allow navigation of the library from where it lands. This was brought about as many a time I’ve wanted to listen to the artist it picked but not the particular album. I also decided to remove the “play” icon and simply click on the album art to launch the media player.

On 19th October 2008 I uploaded a new version that used keyboard shortcuts so you can now navigate around the whole application by keyboard alone:

Alt+C brings up the Configuration dialog.

Alt+I brings up the About dialog.

Alt+S starts the process to choose the next album.

In the configuration dialog as well as the shortcut indicated by the underscores you can change the order of the search for cover images by using Alt+? or Alt+?.

Once an album has been selected Alt+? and Alt+? will cycle through the albums by that artist.

I also been playing with opacity so the application fades out when it becomes inactive or when moved and I’ve been emulating tooltips so that when the album art is right clicked a popup window appears with more details (year, bit-rate, number of tracks, total length etc.) about the album.

On 21st October 2008 I created version 2.0: The application is now multi-threaded and I’ve enabled Esc to abort the search – most useful if you’ve set the wrong library root. The next and previous album buttons are now disabled properly if there are no other albums by the current artist.

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, though you can’t tell that from just running the application.

Future enhancements:

  • Look for music file types other than mp3.

More posts about the Random Album Chooser are:

Updated Random Album Chooser

Another Update to the Random Album Chooser

Application Updates

How the Random Album Chooser Works

The Random Album Chooser, now with integral playback

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

,

1 Comment