Surf the wave

iTunes All Day


It is old news that Apple released the iTunesCOMSdk. A few things are emerging that leverage the SDK:

I've been playing with it and am well on my way to having a full blown PocketPC based remote control for iTunes. The potential synergy with the soon- to-be-released AirportExpress aka AirTunes is exciting.

The iTunesCOMSdk provides access to the underlying component model of iTunes for Windows. You can navigate audio sources and playlists, initiate format conversions, add artwork, create playlist and so on.

Building eyeTuner: eyeTuner is the current codename for my PocketPC based iTunes remote control. You can access a list of iTunes sources (cd, playlists, ipod, etc), select a track or artist, and select next, previous, or pause. eyeTuner also will stream back album art to display on the now playing display as well.

Screenshot 1

The basics of the program were cribbed liberally from Duncan Mackenzie's Laziness .NET article. I chose C# instead of VB, but the basic structure and implementation are very close.

Parsing a playlist:

It is extremely easy to get a list of tracks in a playlist - the largest of which will be the "Library". On my machine, that's somewhere north of 20,000 tracks. Using the iTunes SDK, it takes about twenty seconds to iterate over the library. The following javascript is indicative:


var iTunesApp = WScript.CreateObject("iTunes.Application");

var mainLibrary = iTunesApp.LibraryPlaylist;

var tracks = mainLibrary.Tracks;

var i;

var numTracks = tracks.Count;

var startTime=new Date() ;

for (i = 1; i <= numTracks; i++) {

var currTrack = tracks.Item(i);


endTime=new Date();

var x = endTime-startTime;

WScript.Echo("Total time was: "+ x) ;


Twenty seconds is a long time to keep someone waiting. One could obviously implement a paged access to the library, but rather than seeking complexity I began googleing for alternatives.

iTunesExport is a C# application that allows you to export your iTunes metadata. It includes a C# parser for the iTunes music library. Now one can simply iterate over the XML file that holds all of the iTunes metadata. Like this:



static void Main(string[] args)


int dwStart = System.Environment.TickCount;

LibraryParser ep = new LibraryParser(LibraryParser.getDefaultLibraryLocation());

Playlist[] lists = ep.Playlists;

foreach( Playlist playlist in lists ) {

if (playlist.Name.Equals("Library"))

foreach (Track t in playlist.Tracks) {



Console.WriteLine(System.Environment.TickCount - dwStart);


Running against the same playlist we come up with something around nine seconds. A handsome improvement.

Current Status: eyeTuner is up and running. Basic navigation for the playlists, artists and albums are working. The now playing screen works with album art. Player controls work correctly. Two things that I'd like to work out:

  1. UDP Scanning for eyeTuner servers - in the days of Rendevous, who wants to manually configure IP addresses?
  2. How to access the Radio stations in the radio playlist? Open Issues: Radio Access via iTunesCOMSdk

The radio playlist in iTunes for Windows appears to be a demand loaded playlist. That is to say that if you ask for the playlists for the Radio source, you get a single playlist back. The contents are null until you expand the individual categories in the iTunes application. Each individual station is listed in the playlist only when the category is expanded.

I would love to see some enhanced capability in the SDK around this. It would be a fitting wrap for eyeTuner to be able to source and select any of the radio stations exposed through iTunes.