It's some way to send the audio only through the headphones into an Ionic APP?

I’m trying to achieve this and i don’t know if can be possible…

My idea is create an app who plays different sources of audio and i want only play the audio if the headphones are introduced? Any idea?

Thank fellas