ScriptingBridge causes iTunes to relaunch after quit
- by Justin Voss
I'm working on a Cocoa app that monitors what you're listening to in iTunes, and since I'm targeting Mac OS 10.5 and higher, I've decided to use Scripting Bridge.
If I try to close iTunes too close to the time that my app polls it for the current track, iTunes will immediately relaunch! The only way to reliably prevent this behavior is to quit my app first, then quit iTunes.
Switching to EyeTunes solves the problem, but it's a fairly old codebase and I was hoping that I could accomplish this without an external library. Surely I'm doing something wrong that's causing the relaunch?
Here's some sample code; this snippet is run every few seconds, triggered by an NSTimer.
#import "iTunesBridge.h" // auto-generated according to Apple's docs
-(void)updateTrackInfo {
iTunesApplication *iTunes = [[SBApplication alloc] initWithBundleIdentifier:@"com.apple.iTunes"];
iTunesTrack *currentTrack = [iTunes currentTrack];
// inspect currentTrack to determine what's being played...
[iTunes release];
}
Is this a known issue with Scripting Bridge, or am I using it incorrectly?