PDA

View Full Version : Applescript, iTunes and control




Sdashiki
Feb 20, 2006, 09:58 AM
is it possible to get iTunes info into another application, and use that application to also control iTunes?

basically a front end for iTunes, that lists all the stuff and has all the functionality of iTunes itslef, but in a different layout.

Can you get the info from iTunes in real time and control it as well?

Looking to try to make a Front End for a touchscreen kind of interface....just new to coding and wanted to know if its possible, then look more into it.

thanks



robbieduncan
Feb 20, 2006, 10:33 AM
Yes it's possible. There are plenty of apps that already offer remote control of iTunes.

Edit to add Some basic AppleScript/iTunes examples (http://www.dougscripts.com/itunes/itinfo/info01.php)

Sdashiki
Feb 20, 2006, 10:44 AM
those are scripts to run inside of iTunes.

What I want is a script that can control iTunes from another app.

robbieduncan
Feb 20, 2006, 10:52 AM
those are scripts to run inside of iTunes.

What I want is a script that can control iTunes from another app.

No they are not. These scripts can be saved as stand alone "apps" from Script Editor. To control iTunes from another app you will have to send these commands to it via AppleScript/Apple Events.

The whole Tell application "iTunes" is a bit of a giveaway that they run from outside iTunes.

You could use the scripts as the basis for a simple AppleScript Studio app to control iTunes.

If you are using Cocoa then look at the NSAppleScript (http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSAppleScript.html) class to send the Applescript commands.

Sdashiki
Feb 20, 2006, 10:57 AM
thanks.

what about getting iTunes information to disply?

Like track times, playlists, etc etc.

I am looking to make a touchscreen interface for iTunes.

robbieduncan
Feb 20, 2006, 11:14 AM
thanks.

what about getting iTunes information to disply?

Like track times, playlists, etc etc.

I am looking to make a touchscreen interface for iTunes.

You can query this via AppleScript, but, speeking from experience, it's really slow. I'd use AppleScript for the control and to get the details of the current track (i.e. how long it's been playing) and parse the xml library file for the rest. Apple only creates this file for this purpose, it's not used for anything else. It takes some code I have lying around about 30 minutes to get all the track details from my 7000 song library via AppleScript! You could parse the xml in seconds...

Sdashiki
Feb 20, 2006, 11:17 AM
Ill look into it more, thanks alot.

Applespider
Feb 20, 2006, 11:18 AM
You might want to take a look at what Quicksilver is doing with triggers - and playlists etc through its normal interface.

You can set up triggers to control iTunes from anywhere so Command, Ctrl Space can be Play/Pause regardless of where you are.