Scripting iTunes

Hello ~

as an exercise to learn more about AS, I want to create a schedule of bugle calls (I attended a military college and have some sleepy teenagers who need some “Motivation” to rise and shine occasionally)

I visited the USMC Band site and placed 5 common bugle calls (Reveille being one of them) into a play list called “Bugle Calls”

I put together the following and expected it to play just the track called in the playlist. HOWEVER, it plays each track in turn and doesn’t stop (endless loop)


tell application "iTunes"
	play track "First Call" in playlist "Bugle Calls"
end tell


I’ve looked through the iTunes dictionary and can’t find another verb which would play the specified track and then halt.

I tried STOP and PLAYPAUSE but neither seem to wait for the playing track to complete.

Once I get the track to play once, I’ll start working on the timer piece…

Many thanks

tell application "iTunes"
	play (track "First Call" in playlist "Bugle Calls") with once
end tell

Mike ~

Thanks! That did the trick. I saw the once parameter in the dictionary as a boolean variable and couldn’t figure out the syntax. I appreciate the help (though not sure my teenagers will :slight_smile: )

I’m glad I could help, but, as I recall from my teenage years, I’m not sure that once is the right property for Reveille.

OH, I TOTALLY Agree and am glad that AS has the loop construct to address this very issue.

we have a SONOS system so after I build this and test using iTunes and the speakers attached to my machine, I’ll work on writing a script which will control the SOSOS system and target the zone in the kids’ bedrooms. This, plus a slowly increasing volume level may be enough to do the trick ~

Thanks again for your help.

Cheers!