Bottom to connect select music output to airplay speaker

Hi there

Im trying to create a button that will auto select my airplay speaker in music

I'm struggling with the apple script.

I currently have:

tell application "Music"

possible values for kind are computer/‌AirPort Express/‌Apple TV/‌AirPlay device/‌unknown

set newAirplayDevice to (get some AirPlay device whose kind is "Bedroom Speaker")

set current AirPlay devices to {newAirplayDevice}

end tell

does anybody have anything that works?

Many thanks

Matt

Replied here :wink:

I worked with this script to basically toggle between airplay speaker and MacBook internal speaker. Its a stand alone (switch speakers) button on my media control menus in BTT.

-- Applescript to toggle between two sound outputs by Line number, as they appear in the Sound Control Panel.

set outputA to 1 --change this to the actual 'line number' of your first desired output

set outputB to 2 --change this to the actual 'line number' of your second desired output

--the rest of the script will use these vales as a switch

tell application "System Preferences"

reveal anchor "output" of pane id "com.apple.preference.sound"

end tell

tell application "System Events"

tell application process "System Preferences"

repeat until exists tab group 1 of window "Sound"

end repeat

tell tab group 1 of window "Sound"

-- click radio button "Output"

if (selected of row outputA of table 1 of scroll area 1) then

set selected of row outputB of table 1 of scroll area 1 to true

else

set selected of row outputA of table 1 of scroll area 1 to true

end if
end tell
end tell
end tell
quit application "System Preferences"

Imprint | Privacy Policy