Possible reasons to why the problem occurs;
Power saving feature (both inherent or acquired from third-party applications.
Some users suggest that this can be attributed to a power saving feature in the ROM.
As soon as it hits 30% battery and that activates, it changes all my volume settings. Volume settings auto-adjust themselves?
This suspected feature is also thought to be provided by applications such as AVG optimisation feature etc
Incompatibility issues with headphones with in-built mic
It was observed that when doing an action that generates sound (i.e driving, running etc), the mic input in the head phones, this extra sound is somewhere compensated by a reduction in device volume.
Another possible theory to explain this scenario was described by one user:
When using headphones that does not have built-in controls the phone misinterprets small variations in voltage as commands to adjust volume. These variations are likely caused by phone’s own power saving, peaks in audio being played etc. Such small variations in voltage via the grounding pin are being interpreted by the phone as “volume down commands”. `
Bugs in Android versions
This problem has been noted by many users as a major bug in lollipop and I think earlier versions could have been vitims too. Not only is the Galaxy S4 model affected by this bug, infact other device models e.g LG, Galaxy S3 etc running lollipop version seems to be affected as well.
Possible fixes
Using Volume locking applications
Various applications such as Volume Lock & Mute were shown to be a working solution:
An alternative application Volume Control-Volume Lock has been shown to do the job
- Replacing headphones
Following this evidence:
I found the problem finally. I found that if I use headphones that have a mic built in, it was the cause of the problem. Luckily my headphones came with a lead that could be unplugged from the headphones so I bought a new jack lead with no inbuilt mic and ii fixed the problem.
Another user was affirmative with this workaround:
Long story short, try not to use headphones with an inbuilt mic/volume control esp. while exercising (I find this is often the time this occurs).
- Observing the device in Safe Mode
Try booting your device in Safe Mode. If the problem stops, there is definitely a third-party app triggering it.
However, if the problem is still there, it might be the Android software itself triggering the issue or a hardware-related fault. Simply delete the app that you suspect has compatibility issues with your music player.
- Performing a Factory Reset
When the above solutions do not work, go to Recovery Mode and select Factory Reset. This will totally restore your phone to its factory settings. It will completely wipe all your stored files though, so remember to backup your data prior to this. You also wipe the cache partition in Recovery Mode if even Factory Reset fails.
- Upgrading OS version
If the problem is due to an OS version update, wait for another OTA update that contains a fix from your unit’s carrier or manufacturer. When there are no updates or updates fail to fix the issue, you can root and flash your phone, then, install a custom ROM that will remove the issue. This is very risky though, so do your research about the process first or seek help from a technician.
Other workarounds
Another workaround is using automation. You can try using Tasker ($2.99 but available as a trial version for 7 fays)
Basically here, you want to set the media volume at constant level preferably when playing music or other media:
- We need to create a Profile that can be linked to a certain Task say (Volume lock) when the conditions are met (variable is set to media volume, music app is opened)
Here is a workaround using Tasker:
Task
Go to the Task tab
- Select "New Task + "
- You can name this Task KeepSameVol or anything.
- Click "+" to add new Action
- Audio >> Media Volume [Level :10 (or any value) Dislay (optional just a pop up alert)
- Tap back to exit from this task
- Press back all the way to exit (Your task is saved)
Profile (or Trigger)
Create a Profile which allows setting of predeterminded media volume level:
- Goto Profiles Tab and click the "+"
Event >> Variable set >> %VOLM
Long press the "+" to add another option
State >> Variable value >> %VOLM != 10 (media volume isn't equal to 10)
Long press the "+" to add another option
Application >> Select your Music/Media applications
Tap back to exit from this window

Link the Task to the profile
Explanation: When an media application is opened,acheck is made if the volume is set to a defined level (i.e 10 in this case), if not
equal to ths value then a Taskis processed to adjust the volume to that level and make sure its constant
Hope this helps
References
Volume decreases when playing audio with headphones
Samsung Galaxy S3 Volume going crazy
Why does ringer volume keep going down?
Samsung Galaxy S4 Music Volume Goes Down on Its Own
Possible to lock volume to certain level, so volume buttons don't do anything?
S7 Edge, Volume lock?