-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unable to switch to AirPlay output 'devices' #9
Comments
+1 |
this used to work... +1 |
But: It still let's you switch if you call -s and the exact name of the device! (use "\ " for spaces) |
I don't think it has anything to do with System Preferences being open. At first I thought I had it working for a second too, but really what I see now (with macOS Sierra) is:
Any thoughts @deweller? |
I don't use AirPlay speakers, so naturally I haven't encountered this bug. I'd be happy to review a patch if anyone is able to fix it. |
Also not working for AirPlay devices for me. |
+1 |
Any news on this? 😟 |
Same problem here on High Sierra. |
Whats more so interesting is that |
Even |
Same issue here :( can't use this with AIrplay speakers |
Same here! This project doesn't seem supported anymore, but is anyone created a patch? |
As @deweller said, the developers don't use AirPlay. Someone needs to write the code. |
Not the greatest solution, but a possible workaround with AppleScript. I combined 2 AppleScripts, based on this tutorial: http://apetronix.com/switch-audio-outputs-with-a-keyboard-shortcut-on-os-x/ Set the currentAudioSource to (do shell script "/usr/local/Cellar/switchaudio-osx/1.0.0/SwitchAudioSource -c") |
+1 |
+1 BIG SUR 11.0.1 (20B29) |
The great workaround from @timonvanhasselt sadly don't work under Big Sur. |
I will have a try.... |
Thanks @alanhg! |
I was originally gonna use switchaudio-osx but then AppleScript can do it natively:
|
Great, thank you @demyxco Attention:
|
Here is another one that uses System Preferences but you only changed the "Bedroom" string:
|
I found that I didn't have the energy to learn C and how to release the new package, so I decided to use AppleScript and Shell. it works. Any user who uses Alfred can download this workflow. Easy to switch to any audio include airplay. https://github.com/alanhg/alfred-workflows/tree/master/switch-audio |
@alanhg is the source for that available? |
I took the script folks here have shared and enhanced it to make it more reliable to wait for the volume menu to open before switching to the airplay speaker. I also attached it to a hotkey so I can simply press set soundOutputName to "Dining Room"
tell application "System Events"
tell application process "ControlCenter"
-- Open Sound menu
set soundMenu to menu bar item "Sound" of menu bar 1
tell soundMenu to click
-- Select specified output
repeat until exists checkbox 1 of scroll area 1 of group 1 of window "Control Center" whose title is equal to soundOutputName
end repeat
set soundCheckbox to checkbox 1 of scroll area 1 of group 1 of window "Control Center" whose title is equal to soundOutputName
tell soundCheckbox to click
-- Close Sound menu
tell soundMenu to click
end tell
end tell https://github.com/alphabt/macos-automations/tree/master/Set%20Sound%20Output has more detail on how to setup the hotkey using macOS's Automator workflow. |
of course |
Where? I only see the alfredworkflow file. |
For Apple Script, you can view the readme. I have posted link. https://gist.github.com/alanhg/21f7fd110e0bdac1d0cce66ca40e78ea |
I have similar issue with my SDAC. Figured out, what actual name is "SDAC ", with space, for some reason. |
Thank you @demyxco. |
@Technofrikus no problem, I've made several revisions since then but here's the current one lol:
|
@demyxco Not sure why you are disabling wifi in the beginning? But if I delete the first part, the rest works still great, thanks! Sometimes I have a problem to connect to the HomePod, but changing Wifi doesn't help for me. Restarting the HomePod does though. |
@Technofrikus sometimes my Mac has trouble connecting to the HomePod but this rarely happens. Glad I can help out! |
Was just trying to use this software to so airplay speakers too. +1 |
@demyxco thanks for this little script: set HomePod to "Bedroom"
tell application "System Events"
tell application process "ControlCenter"
set soundMenu to menu bar item "Sound" of menu bar 1
tell soundMenu to click
set soundCheckbox to checkbox 1 of scroll area 1 of group 1 of window "Control Center" whose title contains HomePod
set soundCheckboxValue to value of soundCheckbox
tell soundCheckbox to click
tell soundMenu to click
end tell
end tell I'm trying to use it on macOS Ventura but it is giving this error:
Any ideas how to update it? |
@jdsimcoe As far as I can tell, the new System Settings dont work with AppleScript anymore? I am using the app Keysmith now. Works via simulated mouse clicking, which is not so great, but still better than doing it by hand. |
@Technofrikus thanks for the suggestion! I tried to create a macro to set the sound output to my HomePod but all it did is this, which doesn't do anything: |
@jdsimcoe Yes via Control Center it doesnt seem to work, just tried it. I do it via SystemSettings. |
@jdsimcoe here's a more recent/updated one I have but I haven't used it in Ventura yet since I switched to a bluetooth speaker:
Let me know how it goes. |
Thanks for sharing, @demyxco. I tried your new one but it also doesn't work. I think Ventura just broke a ton of Applescript API stuff. |
@jdsimcoe yeah most likely. When I get more time, I'll try to test it out. |
@noonchen has developed BTAudioSwitch, which is supposed to toggle i.a. previously paired Bluetooth/AirPlay devices. It does detect my HomePod, even when it's not set as the output device, but sadly doesn't toggle it (using the EDIT (fyi): Rogue Amoeba's SoundSource is also unable to detect, let alone switch to, my HomePod. |
I don't have an AirPlay device handy. Did the latest change which replaces the deprecated audio devices help anything? |
Sadly didn't change anything, i.e. However, all the other programs I've tested that allegedly support Bluetooth pairing, switching & connecting incl. audio devices ( But I assume that the approach to setting a Bluetooth audio device as audio output on the command-line is a lot different under-the-hood than with wired or virtual devices… pair first, then connect & establish whether it's even an audio device in the first place, and if yes, select as audio device. (?) |
Addendum: macOS isn't able to handle this either. When I use the system utility Audio MIDI Setup to create an aggregate or multi-output device, e.g. one that includes both "External Headphones" and "AirPlay", macOS will list them in the utility and in the system's sound preferences (devices list), and |
This AppleScript seems to work for me on Ventura… combined from online sources. (Change the name of your AirPlay device in line 1, if necessary.) However, unlike before, the whole new UI scripting with
You can prepend a second audio device comma-delimited in line 1, e.g. "External Headphones", and then the script will first enable the headphones, and then the AirPlay device, which might be a workaround if your AirPlay device is disconnected & doesn't reconnect. |
I didn't find a way to do this in the background, but you can replace the Here is the diff --- a/a.scpt
+++ b/b.scpt
@@ -5,10 +5,11 @@ tell application "System Settings"
reveal anchor "output" of pane id "com.apple.Sound-Settings.extension"
end tell
-delay 2
-
tell application "System Events"
tell application process "System Settings"
+ -- Wait until Sound window is available to interact with
+ repeat until exists window "Sound"
+ end repeat
+
set theRows to (every row of table 1 of scroll area 1 of group 2 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Sound")
repeat with myDevice in myDevices
set theDevice to myDevice as string
And here is the full updated script. set myDevices to {"HomePod"}
tell application "System Settings"
activate
reveal anchor "output" of pane id "com.apple.Sound-Settings.extension"
end tell
tell application "System Events"
tell application process "System Settings"
-- Wait until Sound window is available to interact with
repeat until exists window "Sound"
end repeat
set theRows to (every row of table 1 of scroll area 1 of group 2 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Sound")
repeat with myDevice in myDevices
set theDevice to myDevice as string
repeat with aRow in theRows
if name of first item of static text of group 1 of UI element 1 of aRow is equal to theDevice then
set selected of aRow to true
exit repeat
end if
end repeat
end repeat
end tell
end tell
quit application "System Settings" |
Oh nice! This is great! |
Thank you! 👍 fyi, also for @deweller: @alanhg has forked this repo and is working on a solution to include AirPlay support. See here: https://github.com/alanhg/switchaudio-osx 🤞 |
Update for for Sonoma RC set myDevices to {"HomePod"}
tell application "System Settings"
activate
delay 1
reveal anchor "output" of pane id "com.apple.Sound-Settings.extension"
end tell
tell application "System Events"
tell application process "System Settings"
repeat until exists window "Sound"
end repeat
delay 1
set theRows to (every row of outline 1 of scroll area 1 of group 2 of scroll area 1 of group 1 of list 2 of splitter group 1 of list 1 of window "Sound")
repeat with myDevice in myDevices
set theDevice to myDevice as string
repeat with aRow in theRows
if name of first item of static text of group 1 of UI element 1 of aRow is equal to theDevice then
set selected of aRow to true
exit repeat
end if
end repeat
end repeat
end tell
end tell
quit application "System Settings" I used an app called UI Builder to fetch the UI path. Warm recommendation. |
Following this stackoverflow answer & script I got this slightly modified version to work on my m2 macbook airplay.applescript (you probably just need to update
You can run this like so
|
Hi @davidaberg, This is no longer working in Sonoma. Could you help to fix it? Thanks! |
+1 to a fix but I have fixed the code from hjoelh. Fixed the default install location of SwitchAudioSource (/opt/homebrew/opt/switchaudio-osx/SwitchAudioSource) and added a 1 second delay on the showing the Airplay devices on Audio MIDI Setup - mine would show nothing if the script ran too quickly. Not sure why Github won't display the code in a nice copyable window right now but here it is - ` global initialApplication, initialWindow, currentAudioSource, availableAudioSources set the currentAudioSource to (do shell script "/opt/homebrew/opt/switchaudio-osx/SwitchAudioSource -c") if currentAudioSource is equal to localDevice then -- Switch the current device using switchaudio-osx. -- Connect to the desired AirPlay device. -- Open and focus Audio Devices |
Actually the fix seems to only work half the time - I think theres a bug in Audio MIDI Setup which seems to screw up the listing on Airplay devices every time. |
I'm unable to switch to my airplay 'speakers'
The text was updated successfully, but these errors were encountered: