Recently I received a refurbished iPhone 4s running ios 7. The speaker sound does not work in some applications. For example videos from the Photos app play no sound. However, the ringtone works. Keyboard sounds do not work. The music app does not emit sound either.
I have tried power cycling, updating applications, calling the phone and restoring from backup.
Calling the phone seemed to help as audio returned, but then the same problem resumed about a day later.
EDIT 1: This problem is intermittent. For example when unlocking the first two keys make sound but the third and fourth do not. It does not always fail in this pattern. One moment the sound may be working on youtube, and go silent the next. There does not seem to be any pattern to the failures.
What can be done to fix this?