←back to thread

A bug saved the company

(weblog.rogueamoeba.com)
379 points ingve | 2 comments | | HN request time: 0s | source
Show context
oulipo2 ◴[] No.45023731[source]
I tried Airfoil to be able to do the following:

- redirect my music (eg Youtube music) to my Apple Homepod

- still play all other audio (eg some podcast or video) on my laptop

but it doesn't work / is buggy / either puts everything in one location or the other

Has anyone here found a good setup to redirect the audio from exactly one app to the Homepod, and keep all the rest on the laptop audio?

replies(1): >>45023848 #
oulipo2 ◴[] No.45023848[source]
so playing with Audio Hijack, it seems my "Airplay" audio output is *only* present in the interface if I'm currently choosing "Airplay" as my default audio output from the system

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

replies(2): >>45023911 #>>45024967 #
postalcoder ◴[] No.45024967[source]
> so playing with Audio Hijack, it seems my "Airplay" audio output is only present in the interface if I'm currently choosing "Airplay" as my default audio output from the system

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...

replies(1): >>45031635 #
1. oulipo2 ◴[] No.45031635{3}[source]
Thanks for your message! Unfortunately I tried it but it didn't work on my setup (at least the first osascript)
replies(1): >>45033597 #
2. postalcoder ◴[] No.45033597[source]
you may have to change the spelling of Control Center to Control Centre depending how your computer is localized. The first script should work.