The ability to mute DJ and play an Internet feed became a necessity for my station in Fall 2011. Jay kindly (and quickly!) added the ability to "tell" DJ to mute all three players.
I added some code to DJEvent-NowPlayingChanged that told iTunes to try playing the playlist that contained my remote feed URL, waited 10 seconds, muted DJ if iTunes was playing and then entered a loop that would go for as long as iTunes was playing. It worked well most of the time but still needed work.
I recently converted an LPFM I'm involved with from another product to Radiologik. They have the same needs for remote broadcasts so, of course, I put my script on their system as well. I ran into two things over there... the script didn't work as well for some reason (it wasn't staying in the loop) and they sometimes do remotes during pre-recorded programming. It was only by chance that I didn't run into the second problem at my Internet station, but it did present a problem. I realized that relying on DJEvent-NowPlayingChanged wasn't the right way to go with this.
What follows is a complete rewrite of a script I previously posted in the forum. This is what is does:
- Tell iTunes to play the remote feed playlist.
- Wait 10 seconds.
- If iTunes isn't stopped, set MuteMain3 to true. Otherwise, set MuteMain3 to false.
- Wait 20 seconds and do it one more time.
Basically, you're checking for a remote broadcast every 30 seconds and setting everything to the state it should be in.
~/Music/Radiologik/Scripts/CheckRemote.scpttell application "System Events"
tell application "iTunes"
if player state is stopped then
tell application "Radiologik DJ"
MuteMain3 false
end tell
try
play the playlist named "Remote"
end try
delay 10
end if
end tell
tell application "iTunes"
if player state is not stopped then
tell application "Radiologik DJ"
MuteMain3 true
end tell
else
tell application "Radiologik DJ"
MuteMain3 false
end tell
end if
end tell
end tell
delay 20
tell application "System Events"
tell application "iTunes"
if player state is stopped then
tell application "Radiologik DJ"
MuteMain3 false
end tell
try
play the playlist named "Remote"
end try
delay 10
end if
end tell
tell application "iTunes"
if player state is not stopped then
tell application "Radiologik DJ"
MuteMain3 true
end tell
else
tell application "Radiologik DJ"
MuteMain3 false
end tell
end if
end tell
end tellcrontab* * * * * /usr/bin/osascript ~/Music/Radiologik/Scripts/CheckRemote.scpt