Spotify - Un/pause with 4 finger gesture

I originally used a global 4-finger-tap trackpad gesture to un/pause any media (mainly Spotify). However, my issue is that if I play something on Spotify then go to YouTube, pause a video, and then navigate to a new tab, if I 4-finger-tap (intending to pause Spotify), it will unpause the YouTube video and keep Spotify playing. This gesture works fine if Spotify is the only media that can be played, however on Reddit or YouTube as described above it doesn't work.

afaik I couldn't find any way natively in MacOS to keep Spotify as the "dominant" sound so BTT gestures only affect it, so I tried to use 4-finger-tap on specifically only Spotify (disabling my global one) since I'll only use this gesture on only Spotify 99% of the time. However, it only un/pauses if I'm in the Spotify app.

Is there a way to use the 4-finger-tap to un/pause Spotify regardless of any program I'm in whilst avoiding the YouTube issue above?

Yes. You can use AppleScripting to specifically tell Spotify to play/pause.

I created a Notch Floating Menu (called 'Notchify') to control Spotify from the notch. If you have a MacBook with a notch you could have a try and see what you think using that, and you could also see an example of what the AppleScripts I use to control Spotify look like to assign to your 4-finger-tap trigger.

I just had a very quick go at creating the Trigger and Action you want.

Download it here and see if it does what you want.

This works great, thank you!

One more way to do it: to use apps like "Tuneful" that controls spotify from the menubar, in this app you can define a keyboard key to pause/resume spotify.

I have also used another method to control spotify volume through a keyboard shortcut, I use the action in BTT to send a keyboard shortcut to an app and then I picked to send the keyboard shortcut to control volume to spotify. It works even if the window is minimized.

How to see spotify stats
To see your Spotify stats, use Spotify Wrapped for annual highlights. For detailed insights, try SpotiPie. Log in with Spotify to view your top tracks and hours listened. Artists use Spotify for Artists.