Record in-game audio/media player music from headphones?

So far, I've only been able to record in-game audio/media player music from my speakers. Is there anyway to record in-game audio/media player music from headphones? I have a pair of headphones, and their audio quality is much better.