Can AirPods' double-tap to Play/Pause be made to work in other macOS applications than iTunes? In macOS, it's possible to assign AirPod double-tap to Play/Pause audio (under Bluetooth options; instead of invoking Siri).

But for some reason double-tap Play/Pause only works with iTunes. 

If you use the Play/Pause button on the Mac keyboard, or even send it via the wired EarPods, the command command can be intercepted by other applications like VLC. I also use a Chrome extension called StreamKeys whereby the Play/Pause button can control playback on popular audio and video streaming sites.

Question: Is there a way to make the AirPods control system-wide Play/Pause? If no simple solution exists, could this be done some elaborate way via scripting?
I don't know much about Macs but this is how I got it to work with VLC (generic options described below also):


Set the AirPods bluetooth options to open Siri on double tap
Have something running in the background checking if Siri is open
If it is open, execute Play/Pause and close it, then go back to checking if Siri is open


These are the two scripts required to get the above working:

MacBook-Pro:~ user$ cat airpods_controller
#!/bin/sh
while :; do
    pid=$(ps x |grep Siri.app|grep -v grep|awk '{print $1}')
    if [ -n "$pid" ]; then
        kill -9 $pid
        osascript -e 'tell application "VLC" to play'
    fi
    sleep .5
done

MacBook-Pro:~ user$ cat airpods_controller_launcher 
#!/bin/sh
ps x |grep airpods_controller|wc -l|grep 2
if [ $? -eq 0 ]; then
    nohup ./airpods_controller &amp;
fi


To have it start automatically, just add airpods_controller_launcher to your startup items under Mac Settings and it's hands off from there. Check the checkbox to make it hide on startup and in Terminal options, set the terminal to close on success if you don't want the window to hang around.

To get it working by simulating media keys instead of osascript (to be more generic), the following looks like it would work:
https://stackoverflow.com/a/13396296/494354

To get it working with Chrome and some other apps, this may help: https://github.com/beardedspice/beardedspice