Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > calling iTunes from cocoa app

calling iTunes from cocoa app
Thread Tools
Fresh-Faced Recruit
Join Date: Jun 2004
Location: San Diego
Status: Offline
Reply With Quote
Nov 6, 2004, 02:35 PM
 
I have search everywhere to see it I can call iTunes' Applescript interface directly from a cocoa app and the only solution I found was to call an applescript to call out to iTunes. I am new to mac programming and would like to know if this is the only solution.

Thanks in advance.
     
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status: Offline
Reply With Quote
Nov 6, 2004, 03:30 PM
 
In order to talk to iTunes you have to send AppleEvents, and there are a few different approaches that you can take:

1) Write the application in AppleScript. This approach is really simple to do, but once the project starts to get complicated AppleScript shows its limitations. You can build full applications, with a nice InterfaceBuilder GUI and all, with AppleScript Studio (AppleScript Application in XCode).

2) Create a AppleScript Studio Application, but use the bridges to do most of your heavy lifting in Obj-C or Java, with the portions dealing with getting the information to and from iTunes being in AppleScript. This is the approach I went with for creating a program to access iTunes (random playlist generator).

3) Use the NSAppleScript to send events. Getting results is not necessarily easy.

4) Use CamelBones (Perl) or Cocoa-Python and use their AppleEvents libraries (really quite nice).

Unfortunately the documentation for doing all of this is a bit spotty, and very scattered. I would have a look over at CocoaDev, as I keep finding gens there, and while they don't have anything on this specifically, CocoaDevCentral has a bunch of nice articles.

[edit] Oh.. ya, I forgot about the possibility of using the Carbon AppleEvents classes to do things very manually... I would not recommend this to... well... anyone.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:19 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2