by oulipo2 · 1y ago · 0 comments
So basically with Audio Hijack I can do a "hack" which is: - set my laptop to play on Airplay - play some music there - then if I want to listen to something else on my laptop, I have to create an Audio Hijack pipeline to play some other app on my laptop
Obviously I would prefer the reverse: by default play everything on the laptop, and be able to play a specific app on Airplay... but this doesn't seem to be possible because the "Airplay" device "disappears" from the interface as soon as I stop setting it as the default laptop output
In my case the interface was AirPods. It was incredibly annoying when various audio software would reset its output device whenever they disconnect or auto-switch to the phone. So, I set up a multi-output device that outputs signal to the pods along with the wired headphone port, and configured audio software to output to that virtual device. After that, there is no flakiness: when the pods are connected then they get the audio, if they aren’t then they don’t get the audio, nothing else needs to be changed.
I’ve never used Airfoil though. To be honest, I feel like routing audio through a multi-output virtual audio device might defeat the point of the app if it’s meant to play to wireless devices directly.
Airfoil will maintain a connection with your Airplay device even after resetting your system audio device.
Though not perfect, but you can use applescript to force Airfoil's discovery of your airplay device by way of control center:
tell application "System Events" to tell process "Control Center"
repeat with menuBarItem in every menu bar item of menu bar 1
if description of menuBarItem as text is "Sound" then
set soundMenuBarItem to menuBarItem
exit repeat
end if
end repeat
click soundMenuBarItem
repeat with currentCheckbox in every checkbox of scroll area 1 of group 1 of window "Control Center"
set deviceId to value of attribute "AXIdentifier" of currentCheckbox
set deviceName to text 14 thru -1 of deviceId
if deviceName as string is equal to "DEVICE NAME" then -- DEVICE_NAME is the name of your airplay audio device in control center.
click currentCheckbox
click soundMenuBarItem
exit repeat
end if
end repeat
end tell
Airfoil supports scripting[0] so you can connect an application to the airplay speaker using this AppleScript: tell application "Airfoil"
set safariSource to make new application source
set application file of safariSource to "/Applications/Safari.app"
set current audio source to safariSource
set aSpeaker to (first speaker whose name is "INSTANCE_NAME") -- Paste the Airplay speaker's instance name here
if not (connected of aSpeaker) then
connect to aSpeaker
else
disconnect from aSpeaker
end if
end tell
You can run this command in the command line to get the instance name of your airplay device: dns-sd -B _airplay._tcp
You can make some combination of this to form a workflow that suits you.[0] https://rogueamoeba.com/support/knowledgebase/?showArticle=A...