• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Accessing iTunes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >Accessing iTunes (From: Jerry Brace <email@hidden>)

  • Prev by Date: Re: Wake from Sleep
  • Next by Date: primitiveValueForKey Memory Management
  • Previous by thread: Accessing iTunes
  • Next by thread: Re: Accessing iTunes
  • Index(es):
    • Date
    • Thread