Zune + XNA Game Studio 3.0 = Shuffle By Album

One of my ongoing gripes about the iPhone, the iPod touch, and Zune product lines are that they don’t offer a small, yet useful, feature that the iPod (and iTunes) has offered since 2001: Shuffle By Album.

Thanks to the XNA Game Studio 3.0 development environment and Zune’s support of it, I’ve been able to add this functionality back into my portable media player: my Zune 80.

What is Shuffle By Album? Simply put, it’s when you want the player to randomly select the first track of an album, plays the entire album, and then selects a new album. Pictured a “group by album, sorted by track.” Simple right? It should be. They had it in the Gen 1 iPod 5GB… yet I get the impression that it’s a little used feature.

Why do I care? Because I’ve got a very varied collection of music that was recorded at drastically different volumes. For example, if I was using Shuffle By Song, I could jump from an Offspring song to a Springsteen song to a Les Miserables track… all at different volumes. Bit of a mess. With shuffling set at an album level, I’d stick with the Offspring song until the album ran out and then shift to something else… less jarring.

How did I do it? It all starts with getting the XNA Game Studio 3.0 CTP bits installed… to figure out how to do that, go here: http://creators.xna.com/en-US/downloads – and yes, you want the 3.0 bits. Even though they still released as a Community Technology Preview, it’s the first version that supports Zune; 2.0 only supports Windows and Xbox.

After you get the bits installed, you’ll want to follow the instructions to get your Zune docked and connected to the Visual Studio 2008 development environment. There’s instructions with the XNA GS bits – it’s easy… easy enough that I don’t remember how I did it first go around.

Once your Zune is happy and has a new high level menu item for Games, download my source code for this project through CodePlex. Compile the project and you’ll find the bits waiting for you on the Zune itself.

Project overview: The majority of the heavy lifting for this Zune app is done by the Framework. The Framework exposes all of the information about music library including the track information and album art. That said, within the project there are three major components, all of which were designed to mirror the built-in playback controls of the Zune:

Content – this includes all of the stock bitmaps and fonts that the application uses as part of its UI. [Remember that unlike Win32 applications, there is no stock UI controls in the gaming world so you are literally given a blank canvas to work on.]

ZunePad.cs – this is a generic interface to all of the Zune controls, including the Z-Pad that is part of the new 4/8/80 devices. Picked that up off http://xnawiki.com/index.php?title=ZunePadState and it’s a very handy class to have.

ShuffleByAlbum.cs – the main functionality of the application lives here.

    Features/Instructions:

  • Play/Pause works as you’d expect it to
  • Left/Right is track control – Right is always next; Left is “restart current track” unless its in the first five seconds of a track
  • Up/Down is for relative volume control
  • Center button is next album
  • Back button exits the application
  • Album art is used to show the current, previous, and next album
    Known limitations:

  • Unplugging a set of headphones does not pause playback – no access to see this via the Framework
  • Screen stays on at all times – no access to dim/turn off the screen via the Framework
  • Volume is relative to the app – no access to device-level volume control
  • Application reboots on exit – all games do this
  • Playback-bar outlook is cheesy – no skills for art work

The source is open, for anyone that wants to check it out – it’s fairly straight forward but it’s also written with a game architecture in mine, so Win32 programmers may see things they don’t expect; games programmers might be


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.