It’s not polite to ask a techiebird her age, but I’ll tell you that I’m old enough that most of the music I’ve listened to has been albums, not singles. And many of my albums sound better as albums, i.e. played from start to finish in the order the artist intended.
Sometimes I don’t want to have to decide what to listen to. I just want to hear something good and I want to hear all of it. Or sometimes I just like the familiarity of a compilation playing the tracks in the order I expect. So it’s a shame there isn’t a “shuffle albums” feature in any media player hardware I’ve come across, or any of the major software media players.
However, we have PowerShell, Windows Media Player has an object model, and how hard can it be to create a playlist of complete albums anyway?
Actually, harder than I expected. But, helpfully, James O’Neill wrote about the quirks of the WMP Object Model some time ago, which helped a lot. (Definitely read his two posts on scripting for WMP if you’re thinking of doing something similar. They’re written for PowerShell v1 but everything works much the same.)
Anyway, here’s what I came up with (usual disclaimer applies):
Most of the work is done by the function Shuffle-Albums, which takes the following parameters:
|NumberOfAlbums||How many albums to add to the playlist|
|MinTracks||The minimum number of tracks for an album to be considered ‘complete’. (I have singles and other miscellaneous tracks which have album information in WMP, and the database doesn’t have anything to distinguish these from complete albums. This seemed like the easiest way to avoid having one-track ‘albums’ in my playlist.|
|MinStars||Counter to my argument for having an album shuffler in the first place, some albums have one or two sucky tracks I prefer to skip over. This parameter gives me the option of giving those tracks a low rating and having them missed out from my playlist. Most of my tracks are unrated, so those always get included.|
I’d quite like to put a UI on this but realistically I may never get round to it. If anyone else wants to have a go then I’m very happy for you to use my code as long as you share the results for free :)
And as always, please let me know in the comments if you spot anything I could fix to make the code better.