How to Automatically Pause Your Music When Other Sounds Start Playing

You’re listening to music, but then you click a video. Now both things are playing at once, and you have to pause your music manually like it’s the dark ages. There has to be a better way.