A speaker/headphone can produce sound with only the wire coming from your computer/phone, a magnet, and the cone. The electricity from the audio cable manipulates the magnetic field in the speaker, causing the cone to vibrate.
So while the audio cable is transmitting electricity into the headphones, it's just wrapped around a magnet instead of having other electric components.