If you just want to pause music while you receive and incoming call then you can simply use TelephonyManager to detect an incoming call and pause the music.
Also if you want to pause music while you get any notification sound then you can see the answer How to pause music when phone rings, sms is received, etc?. It fits that need. Also on searching Google using query music pause sms received
, I found that many users complained that Android OS itself pause the music while any notification sound is received. Also there was no setting to turn that off. Since I never tried it personally, I can't tell you on which versions that bug was present. You can research yourself or may ask a new question here, hopefully some knows more than myself.