Background Music is a macOS audio utility that can automatically pause your music, set individual apps' volumes, and record system audio.
Free • Open Source
What is Background Music?
"Background Music can pause your music player app when other audio starts playing and unpause it afterwards. The idea is that when I'm listening to music and pause it to watch a video or something I always forget to unpause it afterwards. So this keeps me from wearing headphones for hours listening to nothing. So far iTunes, Spotify, VLC, VOX, Decibel and Hermes are supported."