A wire that has an electric current flowing
through it, like our 500 turns of copper wire, becomes a magnet (an electromagnet).
If near a permanent magnet, like the one glued onto the
ice-cream container, it will be attract or repulse it, depending on
which poles are close together.
This means the bottom of the container with
the magnet glued on will move back-and-forth with the magnet, slapping
into the air, creating sound waves.
Our walkman supplies the electric current,
but it turns the electromagnet on and off very fast to creating a linear
(back-and-forth) movement rather than a rotational one
(like inside normal motors). The linear motion of the our speaker
"cone" creates air pressure waves
that we perceive as sound.