I have a a new Apple laptop.  Since I'm a relatively new Mac user, I thought I'd spend a little bit of time learning a bit about how to program it.  Since I spend a lot of time in iTunes, I thought I'd learn a bit about how to use AppleScript to control iTunes.  So, on this very snowy New England Sunday morning, I wrote an AppleScript app that watches iTunes and posts to the growl notification system when a new track starts playing.  Here's a screen shot of the app in action:

I'm sure this is not the first time anyone has done this, but it was fun learning how to do something like this.  

If your interested in trying it out, you can grab the application from here. Just toss it into your iTunes script folder (typically in user/Library/iTunes/Scripts.  You can start it from the iTunes scripts menu. 

 

Comments:

Paul, great site, the little perusing I've done that last two days also snowed in (here in Boston). Very interested in audio fingerprinting, both for cleaning up tag data via automated song identification, but also using one's cell phone to ID a song on the spot.

Re: your AppleScript endeavor -- good job. Been a programmer (Perl, C, Pascal, (Apple IIe) machine language) for over 20 years and have been doing AppleScript on and off for years. Just a little frustrating trying to learn AppleScript's terminology. But very fun when it works.

Oh, and you did know about GrowlTunes, yes? Comes with the Growl installer.

Cheers!

Posted by Bob Freeman on December 17, 2007 at 07:42 AM EST #

If you're interested, you can also listen for iTunes track changes via Cocoa's distributed notifications; see NSNotification and friends. (A copy of TildeSoft's Notification Watcher is also highly useful.)

Cleaner than polling, although AppleScript Studio doesn't support notifications so you'll need to use ObjC or something like Python+PyObjC. Ruby+RubyCocoa or maybe Perl+PerlObjC (all are bundled in Leopard too).

HTH

has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org

Posted by has on December 17, 2007 at 01:47 PM EST #

has:

Thanks ... I was particular uncomfortable with the polling model. My ultimate goal is to be able to push the iTunes track changes into a named pipe or the equivalent, so I can scoop the changes up in a java app and have my way with them in the java world. Since the java api for Cocoa has been deprecated, I'll take a look at the PyObjC binding to catch the NSNotifications and toss them into a pipe (unless you can think of a better way).

Paul

Posted by Paul on December 17, 2007 at 01:58 PM EST #

"Since the java api for Cocoa has been deprecated, I'll take a look at the PyObjC binding to catch the NSNotifications and toss them into a pipe (unless you can think of a better way)."

I imagine it's that or writing your own JNI wrapper for the relevant ObjC APIs.

Posted by has on December 17, 2007 at 03:02 PM EST #

Find out more about AppleScripting iTunes at dougscripts.com.

Posted by Doug Adams on December 17, 2007 at 08:29 PM EST #

Doug's Applescripts for iTunes is an excellent resource, and I was remiss to not mention it - I have used it quite a bit to learn how to do all sorts of iTunes manipulations via AppleScript. It is a great site.

Posted by Paul on December 18, 2007 at 05:27 AM EST #

Post a Comment:
Comments are closed for this entry.

This blog copyright 2010 by plamere