We had an iPhone that wouldn’t play thru the built in speakers (the little ones at the bottom). You could send stuff to the headphones (if you plugged in a set), or Apple TV, or thru the Dock – but that is all.
Even when it wasn’t in a dock.
I did some looking around the internet, but didn’t find a solution that worked. So, what I did was to plug it into a dock connector, then apply a little pressure up on the connector while removing it. Repeat, while applying a little pressure down on the connector… Oh, yea, and use a nicely fitting connector (the one that came with the phone appeared to be a little use after all the wear and tear – so I used a different one)
Repeated 4 times, and then checked. Sound came out the built in speakers.
Other solutions I have seen on internet involved a q-tip and rubbing alcohol, I didn’t have either one handy. So, I agree with the idea that it’s crud on the dock connector – just I basically scrapped it off.