When of my biggest pet peeves is not that notification sounds play while listening to music, but that they briefly power its volume. Its like dancing in a club and you get a notification about your uber eats and so the dj tells everyone to quiet down for a bit so that you look at the message.
I am pretty high while writing this, so, just to be safe, here are similar issues: https://android.stackexchange.com/questions/204153/disable-or-change-audio-ducking-lowering which was deemed answered by https://android.stackexchange.com/questions/199918/stop

-notifications-from-briefly-lowering-media-volume.


Use a music player that has a setting for it. I’m a poweramp fanboy