I had the same problem on my iPhone 4 (iOS 5.0.1)
- No volume control (slider or hard buttons) when playing music, games, video etc
- No sound when playing the above
- Sound and volume control returned when head phones plugged in
- Ringer still worked
I read a thread that fixed it for me.
I noticed it after I plugged the phone into my car stereo (has iPhone docking) and then unplugged it after activating the iPhone and playing a video.
To fix it I plugged it back into the car stereo and activated the iPhone (usually when I plug it in the iPhone screen shuts off and I control the music etc from the car head unit). Sound and volume control returned to the iPhone!!
Crazy but it worked. So I guess some docking stations will do the same thing (not just a car stereos)
Mine did the same thing last night. I read several forums and found the solution. I grabbed a can of compressed air and cleaned out the pins (where you plug the charger into the phone), and also cleaned out the docking station (which was a juice pack external battery I bought), then went to my music and everything started playing. It seems dirt or lint can get into the pins compressing them and it sends a signal that the phone is still on a dock making the phone try to play through external speakers.
I got the same problem on my iPhone 4S too. But I can fix it by RendstarAU idea. When I read it, I just understand that when we use headset or earphone that aren't Apple products, it will be stuck by headset logo but iPhone don't show the headset logout the top like other smartphone. So to fix it just use your headset or earphone that when u plugged out and plug it in back. When u plugged out again it will appear back.( if don't, try to restart or reboot your iPhone and plug in and plug out again, also wait for fews minutes too)