Archive for the ‘iTunes 11’ Category
Airplay device properties
These are the new Airplay device properties accessible via AppleScript:
active (boolean, r/o) : is the device currently being played to?
available (boolean, r/o) : is the device currently available?
kind (computer/AirPort Express/Apple TV/AirPlay device/unknown, r/o) : the kind of the device
network address (text, r/o) : the network (MAC) address of the device
protected (boolean, r/o) : is the device password- or passcode-protected?
selected (boolean) : is the device currently selected?
supports audio (boolean, r/o) : does the device support audio playback?
supports video (boolean, r/o) : does the device support video playback?
sound volume (integer) : the output volume for the device (0 = minimum, 100 = maximum)
Notice that all the properties are read-only (r/o) except for selected and sound volume, meaning only those two properties can be changed; the others can only be polled.
Basic Airplay script
This is a pretty basic use of the new Airplay stuff. Select and set your Airplay devices:
tell application “iTunes”
set apNames to (get name of AirPlay devices)
set apDevices to (get AirPlay devices)
set rez to choose from list apNames with prompt “Select Airplay:” with multiple selections allowed
if rez is false then return
set apPlays to {}
repeat with i from 1 to length of apNames
if item i of apNames is in rez then set end of apPlays to item i of apDevices
end repeat
set current AirPlay devices to apPlays
end tell
iTunes 11.0.3 Released
iTunes 11.0.3 was released today. Mods to the Mini player seem to be the most obvious. Under the hood, AppleScript has some new Airplay access.
First, there’s a new Airplay device class and AirPlay enabled and current AirPlay devices application properties which should make scripting Airplay operations pretty easy. I’ll have some stuff later.
The track class gains a iTunes U property (”is this track an iTunes U episode?”).
More as it develops.
iTunes 11.0.2 Released
Apple released iTunes 11.0.2 today. It fixes some iCloud/iTunes Match playlist issues, adds a Composer View, and other fixes and performance enhancements. More as it develops.
iApps.plist Issue?
As you may know, the location of the current iTunes library’s database files can be read from a user preferences file named “com.apple.iApps.plist”. This preferences file also maintains the location of the current iPhoto library and perhaps the locations of other apps’ support files. By default, the location of the current iTunes database files is in ~/Music/iTunes/, like in the screenshot below. If or whenever you select or create a new library by Option-launching iTunes the location you select is stored in the iApps.plist as iTunesRecentDatabasePaths. Third-party apps can then locate the current database by simply reading the meta data from the iApps.plist.

Recently, since the launch of iTunes 11, I’ve been hearing from Correspondents who report that some of my software (apps and scripts) that need to access the iApps.plist are no longer finding the iTunesRecentDatabasePaths data. In fact, their iApps.plist file does not even contain the data. Somewhow it has not been updated correctly. Thus, when an app or script tries to read the iApps.plist it fails with a Console error like “The domain/default pair of (/Users/SomeUser/Library/Preferences/com.apple.iApps, iTunesRecentDatabasePaths) does not exist”.
The fix is, first, to make sure you note the location of your iTunes support files. If you’ve never used the Option-launch method of creating a new library then this location is your home folder’s “/Music/iTunes/” folder. Otherwise, well, I suppose you know where you created a new library. Now, quit iTunes. Hold the Option key and launch iTunes again. In the dialog that appears click the “Choose Library” button. Navigate the Open dialog to the folder you just noted (it will contain an “iTunes Library.itl” file and one or the other of an “iTunes Music Library.xml” or “iTunes Music.xml” file) and click the “Open” button. This should write the location to the iApps.plist correctly allowing scripts and apps to read it without error.
Show Current Song, Really
iTunes 11.0.1 fixes an issue with the “Show Current Song” (the Command-L shortcut). Before iTunes 11, using this command would select the currently playing track in the playlist it was playing from. In iTunes 11 there seemed to be some inconsistency with this behavior in different playing contexts. But now with iTunes 11.0.1 the command consistently selects the currently playing track in that track’s library regardless of its playlist source (if any). Coincidentally, this also happens to be the task performed by a script I wrote about to workaround the afore mentioned inconsistency.
I frequently find it convenient to access the playlist a track is playing from but “Show Current Song” doesn’t do this any more. So here is a script that selects the currently playing track in its source playlist (the pre-iTunes 11 behavior). I’m guessing the reveal command was fixed because this didn’t work quite right with iTunes 11, or maybe it had to do with those inconsistencies.
Interestingly, the playlists list will become visible if it is not already and the correct track selected. The try block prevents an error in case the script is run while iTunes is not playing, in which case there is no current track property. Attach a shortcut. Option-Command-L might be a good one. (Shift-Command-L is used by the “Search With Google” Service.)
Looks Like reveal Works Correctly
iTunes 11.0.1 appears to fix the issue with the AppleScript reveal command, mentioned here. But Command-L (Go to Current Song) apparently does not yet work correctly. Update: Go to Current Song/Command-L does work correctly. But it doesn’t select the track in the playlist it may be playing from; it selects it in the Music library. This AppleScript will select the currently playing track in the playlist from which it is being played:
iTunes 11.0.1 Released
Apple has released iTunes 11.0.1, an update that makes some fixes to AirPlay, iTunes Match, and provides the obligatory “stability and performance improvements”.
Show Track Count and Time of Selected Playlist
There’s seems to be a bit of inconsistency with the way iTunes 11 displays playlist time information as DD:HH:MM:SS. Sometimes times are displayed in the Status Bar at the bottom and sometimes a decimal version will be displayed beneath the playlist’s name at the top of the browser. I can’t quite get a grasp on something like “7.6 days” though.
Here’s a script you can attach a shortcut to that will simply display a dialog box listing the name of the selected playlist, the number of tracks it contains, and the time of the playlist as DD:HH:MM:SS:

Interesting play Issue with MiniPlayer
As I mentioned below, I had to fix a script to workaround a problem playing a playlist when only one track had as yet been copied to it, which prevented the rest of the subsequently added tracks from being recognized by MiniPlayer and Up Next; thus, only the first track would play. Similarly, if you were to play (the AppleScript command) any track in a playlist, the following tracks will not play because they haven’t been recognized by MiniPlayer and Up Next (”No upcoming songs”).
Doesn’t go good when Mini Player is empty:
You can play the playlist and everything’s OK. You just can’t initiate play of the entire playlist by playing one of its tracks with AppleScript.
Goes good and loads in MiniPlayer:
Additionally, I found that if the MiniPlayer was already loaded up with tracks, playing a track (via AppleScript) from anywhere would play that track and then resume with whatever is next in MiniPlayer.
