I can't hear songs on a lot of my stuff! (iPhone 4)?

So some/most of the time the sound on my iPhone is working fine (I can go on YouTube, watch vines/Instagram, hear music in games). But every once in a while the sound will randomly stop working. Usually I can still hear sounds on games or when I type/turn my phone on/off, but when I go on YouTube or vine, I can't hear any sound! I looked in my settings at the sound to see if it was off and it was on. Then a while later (a few days, sometimes weeks or months), the sound will work fine again for a little while until it randomly stops working again! How do i fix it? Please no rude comments, I just recently got this phone and I would just like some help if you have any.

If you got it from the apple store or any carrier as a new phone, then you have a 1 year insurance from the apple store. You can set an appointment online to the genius bar at the apple store, and take it their and explain this problem. They will most likely give you a new phone. I have an iPhone and i replaced it like 4 times. You can also try restoring your iPhone through a computer. One of the biggest reasons for this is when people don't upgrade the software on the iPhone.