Listening to events generated by iTunes on OS X

Is it possible to listen for events generated by iTunes running on OS X? When iTunes is running on Windows it is possible to listen for, say, “OnPlayerPlayEvent” - an event which is fired every time a song starts playing.

More than a year ago now, when I wrote “Using the iTunes COM Interface with Java and Swing”, I talked about being able to listen for these events under Windows. At the time someone asked if it was possible to do the same thing under OS X, to which I glibly replied “sure, use AppleScript”. Of course, I’d never actually used AppleScript myself at that point. Fast forward to last week, when I decided to have a look at listening to events under OS X. Bummer - no listening for events anywhere to be found. I’ve done a bit of Googling, and there are a few other reports of confused people like me not being able to find out how to listen for events.

So, does anyone out there know if it’s possible to do what I want under OS X? If it’s not, the little application I’m writing is going to have to keep polling iTunes to see what its current status is - hardly ideal.

It just doesn’t seem right that the Windows port of iTunes has better programmer connectivity than the original OS X application.

If you enjoyed reading this and would like other people to read it as well, please add it to, digg or furl.

If you really enjoyed what you just read, why not buy yourself something from Amazon? You get something nice for yourself, and I get a little bit of commission to pay for servers and the like. Everyone's a winner!

comments (3) | write a comment | permalink | View blog reactions


  1. by Dominik on August 10, 2006 09:51 PM

    Hi there,

    I just stumbled over the same problem. Did you find out how to make iTunes tell you what it is doing?

  2. by Neil Crosby [TypeKey Profile Page] on August 11, 2006 06:27 AM

    Hi Dominik,

    I’m afraid that in the end I just started polling iTunes every second or so to see what it was doing. Not a great solution, but it was the only one that I could see.

  3. by kd on February 7, 2007 09:16 AM

    I’d like to be able to do the following:

    increase rating by one point if track play count increments. decrease rating by one point if track skip count is incremented.

    Any ideas at all?

other relevant pages

about wwm is a resource for web developers created by Neil Crosby, a web developer who lives and works in London, England. More about the site.

Neil Crosby now blogs at The Code Train and also runs, The Ten Word Review and Everything is Rubbish.