There's no support in Android for recording output streams. There might be phones that support it in some fashion, but that'll be completely vendor specific and not something you can expect to work on any Android device.
Voice call recording is a special case, because voice call audio aren't regular streams that are managed by applications. Many Android devices support recording of both the voice call uplink and downlink using the VOICE_CALL/VOICE_DOWNLINK/VOICE_UPLINK audio sources.
When you say that you were able to record the playback without headphones, what I suspect actually happened was that the microphone picked up what was coming out of the loudspeaker, rather than some form of internal recording of output streams. Recording the loudpeaker output through the primary microphone is certainly one way of doing it, but the resulting recording is probably going to sound really bad.