King Kovifor Posted December 24, 2007 Share Posted December 24, 2007 Hey, I am a relatively new programmer, and by that I mean I am new to OS X programming. I do a ton of non-OS X programming. But to get to the point. My current project is a small and tiny application that fetches the currently playing song from iTunes. I have the retrieval part with a ton of trial in error. I did this through scripting bridge, that new framework introduced within Leopard. Once the application is launched, I have to manually refresh the currently playing song from iTunes to have it shown in the menu bar... Is there anyway to have a function (- (IBAction)updateData;) be called anytime that the song changes within iTunes? That way no manual interaction is required from the user. I have spent the whole day trying to get this working. I got the scripting bridge and updating of the menu bar item done this morning after a bit of messing. Any help would be appreciated, King Kovifor Link to comment Share on other sites More sharing options...
King Kovifor Posted December 31, 2007 Author Share Posted December 31, 2007 Since you guys were OH so helpful, I thought I would tell you I finished this. I'm actually working on new features as I type this. Link to comment Share on other sites More sharing options...
thePixeler Posted January 1, 2008 Share Posted January 1, 2008 Glad we could be of service. Link to comment Share on other sites More sharing options...
King Kovifor Posted January 2, 2008 Author Share Posted January 2, 2008 Glad we could be of service. It was sarcasm. Link to comment Share on other sites More sharing options...
thePixeler Posted January 2, 2008 Share Posted January 2, 2008 It was sarcasm. I know. Just out of curiosity, can you detect when a song changes automatically, or do you have to use a timer and keep checking to see if it has changed. Link to comment Share on other sites More sharing options...
King Kovifor Posted January 2, 2008 Author Share Posted January 2, 2008 You can do it automatically... Here is the code: [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(whatFunctionYouWantCalled:) name:@"com.apple.iTunes.playerInfo" object:nil]; Don't forget to remove the request for notifications with: [[NSNotificationCenter defaultCenter] removeObserver:self]; I suggest that bit in a -(void)dealloc {} overwrite then [super dealloc];! Link to comment Share on other sites More sharing options...
Recommended Posts