Detect audio Safari

I have created a Macro to detect is the URL is YouTube, if so then the macro switches audio input.
But what I would like to achieve is detecting is Safari is playing audio.
Does anyone know a way to detect if audio is playing in Safari?

I don't know how to detect audio from Safari, but this seems to detect when video is playing in my brief testing. Of course, this won't work for Soundcloud/Spotify etc.

Is Safari Playing a Video?.kmmacros (22 KB)

Macro screenshot

1 Like

You might be able to use KM's Image Detection if Safari is frontmost, and look for the speaker icon in the address bar. I mention that because it might be quicker than using AppleScript's notoriously slow "System Events"...

But here's a macro that does use "System Events" to do the same thing, relying on the fact that when the speaker icon is there it is "button 3" but when nothing is playing the "Reload" button is number 3. Tested on macOS 10.14 -- things may have moved since then, so if it doesn't work then let us know the OS you are running.

Is Safari Playing?.kmmacros (2.8 KB)


It isn't perfect, but this solution fits my needs the most. This way I can auto-disable my BT connection to my Nest Speakers (because of the audio delay when connected as a stereo pair) when watching video on Youtube etc. Thanks!

1 Like