i was suspicious of this too, and went through several steps to isolate an apparent (but possibly silly) cause.
The “Now Playing” playlist is being built correctly, you can even watch the tracks disappear and repopulate, correctly placing interstitials and the selections from the source Smart Playlist in order.
But the Script kept hanging on the “Parameter Error.”
I thought maybe the video type TV Show had some inherent play-once-and-stop quality, so i switched some files to Music Video. This made no difference to the script (still “parameter error”),
BUT the playlist would at least play in iTunes by hitting space bar or selecting play.
HOWEVER, the playlist seemed determined to shuffle.
On a hunch, i searched the options on the file to uncover “Skip While Shuffling””apparently enabled on all videos by default? I unchecked that, and now the script is able to run, populate, and PLAY… albeit inexplicably as a shuffled list. So, the script was hanging because it refused to play a shuffled list? and there appears to be no way to just tell it to Play the Playlist in order…? as I said, this is silly, which makes me think I have not found a solution, merely some kind of curious workaround.
On that note, I implemented a quick routine to play the playlist track-by-track in the script itself, which provides the added bonus of a definite end (no need for an “on idle” check to wait out the playlist). However, in a baffling twist, the tracks still seem determined to shuffle… It’s a crazy world.
The current mostly-functioning script it attached below. It is nicely streamlined, thanks to both you fine gentlemen for your patience.
I will keep working and keep you posted. drop a line with any additional insight.
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
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 MergedTracks to {}
repeat with i from 1 to (count of tracks of playlist PlaylistTVShow) -- length based on requested TV Show
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
activate
set view of browser window 1 to playlistMerged
tell application "System Events" to tell process "iTunes" to set value of attribute "AXFullScreen" of window 1 to true
repeat with i from 1 to (count of tracks of playlistMerged)
play track i of playlistMerged
end repeat
-- then, at end of playlist, display UpNext card or Test Pattern or something...
end tell
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
iTunes window showing playlist:
iCal window showing example schedule (not really “Bugs Bunny” all day, that’s just for testing)