i cannot get past the mysterious “parameter error.”
In fact, under analysis, i cannot get iTunes to play anything via AppleScript.
I tried several different ways to get any playlist at all playing; no results.
Eventually, i just tried to get anything to play…
tell application "iTunes"
activate
play
end tell
Nothing. iTunes just sits there.
I engaged in a little code cleanup, basically fiddling while Rome burns.
Here is the latest version of the script, which does everything except actually play…
set PlaylistTVShow to ({first item of my text_to_list((do shell script "/usr/local/bin/icalbuddy -eed -nc -b \"\" eventsNow"), return)} as text) --Get Current Calendar Event via iCalBuddy hasseg.org/icalBuddy
global playlistUpNext
set playlistUpNext to "[some filler playlist TBD]"
tell application "iTunes"
--Shuffle based on "CK's Evenly-shuffled Playlists v0.6" by Charles Kelly http://www.manythings.org/mac/
set playlistMerged to "Now Playing"
set PlaylistInterstitials to "[ID-D]" -- Intersitials for the [D]aytime broadcast
if (not (exists playlist playlistMerged)) then
set playlistMerged to make new user playlist with properties {name:playlistMerged} -- if no playlist, make it
else
set playlistMerged to user playlist playlistMerged -- if playlist, clean it out
delete tracks of playlistMerged
end if
set x to count of tracks of playlist PlaylistTVShow -- length based on requested TV Show
set MergedTracks to {}
repeat with i from 1 to x
set theTrack to some track of playlist PlaylistInterstitials
set enabled of (duplicate theTrack to playlistMerged) to true
set MergedTracks to MergedTracks & (database ID of theTrack)
set theTrack to track i of playlist PlaylistTVShow
set enabled of (duplicate theTrack to playlistMerged) to true
set MergedTracks to MergedTracks & (database ID of theTrack)
end repeat
play playlistMerged
end tell
on idle --wait for playlist to finish
tell application "iTunes"
try
if player state is not stopped then return 5
on error
return 5
end try
play playlist playlistUpNext
end tell
return 5
end idle
on text_to_list(txt, delim)
set saveD to text item delimiters
try
set text item delimiters to {delim}
set theList to every text item of txt
on error
set text item delimiters to saveD
end try
set text item delimiters to saveD
return (theList)
end text_to_list