Background Music is a macOS audio utility that can automatically pause your music, set individual apps' volumes, and record system audio.
"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."
volume-manager recording record-output volume-control volume-settings volume-adjustment