Re: Accessing iTunes
Re: Accessing iTunes
- Subject: Re: Accessing iTunes
- From: Mark Knopper <email@hidden>
- Date: Sun, 29 May 2005 01:42:28 -0400
On May 29, 2005, at 12:01 AM, Jerry Brace wrote:
Does anyone know how to communicate with iTunes via Cocoa (not
AppleScript)?
I need access to Play/Stop functions and start a playlist of choice.
Well if you do want to use Applescript from Cocoa, I have some code
that does this (see example below). The remote machine needs to have
Remote Apple Events turned on in the sharing prefs.
Mark
-(IBAction)play:(id)sender
{
NSAppleScript *playScript;
NSAppleEventDescriptor *descriptor;
playScript = [[NSAppleScript alloc] initWithSource:
[NSString stringWithFormat:@
"set remMachine to \"eppc://%@\"\n \
\n \
tell application \"iTunes\" of machine remMachine\n \
using terms from application \"iTunes\"\n \
\n \
play\n \
end using terms from\n \
end tell\n \
return",
remoteHostName]];
descriptor = [playScript executeAndReturnError:nil];
[playScript release];
[self getNowPlaying:self]; // update now playing window.
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden