First thing first, you should know that there a few basic solutions you can try, just to make sure that it’s not a hardware issue causing this:
Check the phone’s volume: Simply press the volume rocker up, in order to increase the volume. Maybe the phone was on silent, which affected the media volume as well.
Restart your phone: A simple reboot can be the solution for many problems.
Clean the headphone jack: If you’re having this issue only when the headphones are plugged in, try cleaning the jack. Also, try another pair of headphones, since it could be them causing the problem.
Clean the speakers: There some smartphones which have some pretty unusual grills for the speakers and they tend to accumulate a lot of stuff which eventually blocks the speakers from emitting sound. However, don’t use a needle or a toothpick, since this can instantly damage the speaker. Instead, rely on a Q-tip for this.
Clean the cache of your music app: Go to Settings > Apps and look for your default music app, then tap on it. Look for the Clean cache button and tap on it.
Check for any moisture or water-inflicted damage: Turn off the phone, remove the battery, as well as the SIM and memory card, and see if there’s any moisture or residue inside the phone, which can affect its normal functionality. Eventually, by using the dryer on low heat, keep it for a few seconds over the phone.