I have this issue fairly often. Turns out the phone keeps thinking there are headphones plugged in and trys to route the sound there.
When its doing it, try the volume controls on the side of the phone, and see if it says (headphones)
If it does, then there's your problem. Now I have no clue how to fix it.