0

I'm trying to observe iTunes track changes on a local network machine. I have a scripting bridge object and can pass commands to it, but in order to find out any information I have to poll it. I thought distributed objects might be a solution, but I'm not sure if it's possible to observe any of the values this way. Has anyone had any success with this?

Jesse
  • 551
  • 1
  • 5
  • 8

1 Answers1

0

To use distributed objects across the network in this fashion, you'd need to have a server running on the iTunes machine that a client on your local machine connects to. Distributed objects is a relatively simple way to do this.

You can listen for iTunes track change notifications using distributed notifications, but these are only posted on the local machine, so your server would need to listen for these and then notify the clients. You can register for notifications like so:

NSDistributedNotificationCenter* nc = [NSDistributedNotificationCenter defaultCenter];
[nc addObserver:self
       selector:@selector(trackChanged:)
           name:@"com.apple.iTunes.playerInfo"
         object:nil];

Your trackChanged: method would look like this:

- (void)trackChanged:(NSNotification*)notification
{
    NSLog(@"%@",notification);
    //do something with [notification userInfo].
}
Rob Keniger
  • 45,830
  • 6
  • 101
  • 134
  • Thanks, Rob. That's almost the exact way I was doing it on the local side. I was hoping there might be an easier way than creating a server on the remote machine, since you can create Scripting Bridge objects on remote machines. But I'll definitely look into the server/client model. – Jesse Mar 19 '12 at 13:59