I have developed an app that does exactly that. Took several months to develop it, it's definitely feasible and I use it on a daily basis whenever I listen to music. You can try:
https://play.google.com/store/apps/details?id=net.festinger.autovolumefree