Both loudness and exposure time matter. Reduce the volume when you can, move away from loudspeakers and take breaks. At a loud venue, properly fitted hearing protection can reduce the amount of sound reaching your ears.
If you turn up headphones to cover surrounding noise, move somewhere quieter if possible. Use your device’s sound-exposure warnings where available. Two devices showing the same volume percentage can produce different sound levels.
Seek a hearing check if ringing, muffled sound or difficulty hearing persists after loud exposure. Record when the symptoms began and what you were exposed to, so a healthcare professional can evaluate them.