dougscripts.com

May 17 2016 - 12:01 pm

Setting player position Can Fail

Setting the player position while the iTunes player state is paused resets the player state to stopped and resets the player position to 0.

tell application "iTunes"

play -- initialize the state to Play

pause -- put iTunes in Pause mode

set player position to 5

log (get player state) -- will be stopped

log (get player position) -- will be 0

end tell

Attempting a workaround, I found that as long as the track isn't paused, the player position can be set.

This did not occur in previous versions; setting the player position while paused would, as expected, move the play head to that position. In fact, Needle Drop uses a variation of this to begin playing a track at a user-set start time. Needless to say, this won't work with iTunes 12.4. (Hat-tip to Correspondent Rob Robinson.)

[UPDATE: Needle Drop v5.3 addresses this issue.]

[UPDATE ALSO: this issue is fixed in iTunes 12.4.1.]

May 17 2016 - 9:34 am

Music vs music

The AppleScript issue in iTunes 12.4 whereby filtering special kind by Music fails is caused by a conflict with the new media kind property. One of the values it uses is music.

Bugs are being filed. (Hat-tip to Correspondent Nate Weaver.)

May 17 2016 - 7:04 am

Lanced Anxiety

Apple's refresh of the iTunes interface in the latest version and the addition of new AppleScript properties has lanced any anxiety I had about the future of file handling and the future of iTunes AppleScripting. In short: I think we're good for a while.

There's been a lot of chatter lately about Mark Mulligan's projection numbers that suggest Apple could shut down the Store sooner than later. Hot on the heels of this portent was deletegate. Suddenly, iTunes was doomed, your music collection could evaporate, and the Hellmouth would consume us all.

I don't believe Apple would have gone to the effort of adding so much new AppleScript stuff if the roadmap pointed to dropping AppleScript altogether anytime soon. And by the same token, those of us who still rely on iTunes to manage our media files (as opposed to going all-cloud, all the time) can be encouraged by the addition of—for example—the file-related purchaser and downloader properties.

So, while the cloud and streaming are certainly going to be part of the iTunes/Music.app experience, I'm confident that we old-schoolers can still Rip-Mix-Burn easy.

May 16 2016 - 6:53 pm

Finally, What select Does

The new select command is evidently used to bring a visible but obscured window to the front. The browser window, miniplayer window, EQ window and video window can receive a select command.

May 16 2016 - 5:42 pm

The Return of shuffle and repeat

The shuffle commands are now application properties. Back in the day, each playlist could be set individually via AppleScript to shuffle and/or repeat. Those were deactivated when playlists were re-vamped under iTunes 11. At the time, shuffle and repeat became global settings and were no longer 'scriptable.

Well, they're back. But not for individual playlists, just as global settings. The new properties are shuffle enabled (taking true or false as values) and shuffle mode (songs/ albums/ groupings). The new song repeat property takes the old off, one, and all parameters.

[UPDATE: To be clear, the obsolete shuffle and song repeat have been removed as playlist properties.]

May 16 2016 - 4:45 pm

Busted: special kind syntax?

In iTunes 12.4, I can't get a reference to the Music library playlist by doing this:

tell application "iTunes"

set musicPlaylist to (get some playlist whose special kind is Music)

end tell

...because iTunes apparently doesn't recognize the Music value for special kind. When the script is compiled it changes the Music value to lower case:

tell application "iTunes"

set musicPlaylist to (get some playlist whose special kind is music)

end tell

...and the script fails. A lot of my scripts use this to target a particular media library, like Music or Movies.

I suspect, (maybe? perhaps?) that the new select command is related? But, until now, I haven't been able to get any object to react to select. More as it develops.

UPDATE: Well, this works (coercing the value of special kind to text), but it shouldn't have to be done this way:

tell application "iTunes"

set nonSpecial to every user playlist whose special kind is not none

repeat with aP in nonSpecial

if (special kind of aP as text) is "Music" then

log "HEY"

end if

end repeat

end tell

UPDATE ALSO: Correspondent Nate Weaver tweeted to remind me that the event code «class kSpZ» can be used instead of the boinked Music value.

UPDATE ALSO ALSO: Here's the problem.

May 16 2016 - 3:33 pm

current playlist

Like current track, current playlist will recognize an Apple Music playlist. Should have mentioned that before, eh? While you can get properties of cloud tracks and playlists—say, the description of a For You playlist—you cannot change them.

May 16 2016 - 3:00 pm

purchaser

Along with downloader Apple ID/name (mentioned earlier), there are also purchaser Apple ID and purchaser name properties of track.

May 16 2016 - 2:55 pm

media kind

Previously, one could only change the video kind of a track. A new media kind property handles switching among alert tone/ audiobook/ book/ home video/ iTunes U/ movie/ music/ music video/ podcast/ ringtone/ TV show/ voice memo/ unknown. Changing this will place the track entry into the appropriate library; it will remain in any current playlists. Again, another highly desirable ability, AppleScript-wise.

May 16 2016 - 2:50 pm

cloud status of a track is a Thing

iTunes 12.4 now has a new cloud status property of a shared track whereby such a track will be one of the following: unknown/ purchased/ matched/ uploaded/ ineligible/ removed/ error/ duplicate/ subscription/ no longer available/ not uploaded. This has been long in coming.

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.