Why does the sound on my iphone cut out?

It will cut out for like 30 min then work for 5 seconds then cut out for another forever. It just started happening one day, it's all sounds the ringtones, the games, the music everything. I thought there was something wrong with the speakers but then even when I plug it into a cable or plug in headphones it does the same thing, so what exactly is it and can it be fixed?

You might want to upgrade your iOS on your phone or just turn it off wait 3sec then turn it back on