Partager via


Automating iTunes .NET is now easier!

Back in May, I posted about Automating/scripting iTunes on Windows. I noted how it would be easier if IITTrackCollection implemented IEnumerator so you could use foreach. Well, Apple listened, and in iTunes 4.7, it does! Now, you can just write:

using System;

using iTunesLib;

namespace TrackLister

{

class Program

{

static void Main(string[] args)

{

iTunesApp app = new iTunesAppClass();

foreach (IITTrack track in app.LibraryPlaylist.Tracks)

{

Console.WriteLine("{0} by {1}", track.Name, track.Artist);

}

}

}

}

 

Thanks, Apple!

 

Dan

Comments

  • Anonymous
    November 30, 2004
    And what if they did it anyway, WITHOUT reading your blog?!? ;-)
  • Anonymous
    November 30, 2004
    You mean everyone at Apple doesn't read my blog?
  • Anonymous
    November 30, 2004
    Cool! This is should be waaaay faster than the old method. Have you done any perf analysis on this yet?

  • Anonymous
    November 30, 2004
    If I had a nickel for every time I've said "thanks apple", well.... oh wait... I DO! HAHAHAHA I love being rich.

    Thanks Apple should be our company trademark.

  • Anonymous
    December 01, 2004
    I haven't timed it, but I don't imagine there's much of a perf difference in either direction. The same basic thing is happening in either case. It's mostly just easier syntax-wise.
  • Anonymous
    December 02, 2004
    thanks. this kinda information was exactly what i was looking for. are there any other website with more general examples and additional information?