Pause any music - only looks at Spotify/Music.app but customisable

I'm often switching between Spotify and Music.app and find that what Mac targets when using pause media key can sometimes be unpredictable. This little script will pause either if playing.

Open pause-any-music in Script Kit

// Name: Pause Any Music
// Description: Pause music playing from music apps
// Author: Josh Davenport-Smith
// Twitter: @joshdprts
import "@johnlindquist/kit";
const pauseScript = `
tell application "Spotify"
pause
end tell
tell application "Music"
pause
end tell
`;
exec(`osascript -e '${pauseScript}'`);