AppleScript Changes in iTunes 2.0.4

iTunes version 2.0.4 was released on March 20, 2002 and added several new commands and properties. Most of these additions emulate commands in iPod in some way or another; the new 10GB iPods were announced with this version of iTunes, so it's not surprising. [mar 26 '02]


New player commands

Five new commands have been added to the iTunes Suite. The three new "transport" commands are back track, playpause, and resume.

The command back track will restart playing the current track from the beginning, or, if iTunes is paused or stopped at the beginning of a track already, it will cue to the previous track. This is not the same as the commands rewind or previous track. This is the same, however, as pressing-and-not-holding the iPod's left button (or "west" button, I suppose).

Along the same lines is resume. This command resumes playback during fast forwarding or rewind, the same as pressing the iPod's "south" button while fast forwarding or rewinding.

Here's a useful one: playpause. This toggles the player state of the current track between play and pause. Of course, this is the same as pressing the iPod's "south" button during play or pause.

These are simple commands to use; like, you know:

tell application "iTunes"
	back track
end tell

[upm] click to open in Script Editor

(For a discussion of other iTunes commands, see Commonly Used iTunes Commands.)

New and iPod-related is update. It updates the contents of the specified iPod. This again is an area with which I am personally unaquainted and I am awaiting a full report from corresPODents ;)

Finally, convert. This new command will enable you to use AppleScript to convert tracks (ie, rip from a CD) using one of the three built in encoders, WAV, AIFF, or MP3. This topic deserves its own page, but until I get it written have a look at the script Rip A Few My Way which uses a converting routine.

New and updated application properties

All we see here this time is converting, which is a boolean read-only value that specifies whether iTunes is currently engaged in the act. You would want to check this if you thought your script might try to access iTunes during the conversion process, I suppose. Perhaps it may also keep iPod from bothering iTunes while it's busy (it was removed in a later version).

In other property news, note: iTunes version 2.0.3 introduced a "bug" whereby the property player state reported "stopped" even if iTunes was really "paused". This was not fixed in v2.0.4 and may not be fixed anytime soon. For the foreseeable future, the player state value "stopped" will be returned whenever iTunes is "stopped" or "paused".

New track properties

Two new entries: start and stop. These correspond to the start and stop times that can be set in the Info Window under the "Options" tab. You can get and set start:

tell application "iTunes"
	copy item 1 of selection of front window to thisTrack
	set thisTrack's start to 5 -- number of seconds
	get start of thisTrack -- works on current track as well
end tell

[upm] click to open in Script Editor

Regretably, the stop property does not work properly (because it's already a command name!) and you have to use the raw data «class pStp». The chevons are created with Option-Backslash and Option-Shift-Backslash. This is fixed in a future update, however, I don't know if there was ever a fix in the OS 9 version of iTunes 2.0.4, it being the last of the line for OS 9.

Site contents © 2001 - 2024 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Privacy.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
The one who says "it cannot be done" should not be interrupting the one who is doing it.