I need to insert an AppleScript class name into a list without the quotes so I can enable AirPlay.
i.e. I would like my script to create the following list depending on user interaction:
{AirPlay device "Computer", AirPlay device "Apple TV"}
Note the placement of the quotes.
Then I can use this list to turn on AirPlay and stream to the selected devices.
e.g. tell iTunes to set current AirPlay devices to AirPlayDevicesSelectedList
Below is my script so far but it does not work because the quotes in the list of devices are in the wrong place!
So how do I insert the class name AirPlay device
into a list without the quotes?
I suspect the fix may involve changing the AppleScript delimiters.
tell application "iTunes"
if AirPlay enabled is true then
display dialog "Would you like to turn off AirPlay?" buttons {"No", "Yes"} default button "yes" with title "AirPlay"
if button returned of result = "Yes" then
set current AirPlay devices to {AirPlay device "Computer"}
end if
else
display dialog "Would you like to turn on AirPlay?" buttons {"No", "Yes"} default button "No" with title "AirPlay"
if button returned of result = "Yes" then
set airPlayDevices to (get name of every AirPlay device)
log (airPlayDevices)
set airPlayDevicesSelected to choose from list airPlayDevices with prompt "Select one or more AirPlay devices" default items {"Computer"} multiple selections allowed yes
log (airPlayDevicesSelected)
set airPlayDevicesSelectedFix to {}
log (count of airPlayDevicesSelected)
repeat with i from 1 to count of airPlayDevicesSelected
set end of airPlayDevicesSelectedFix to "AirPlay device " & item i of airPlayDevicesSelected
end repeat
log (airPlayDevicesSelectedFix)
set current AirPlay devices to airPlayDevicesSelectedFix
end if
end if
end tell
set end of deviceList to first item of (AirPlay devices whose name is "computer")
– red_menace