Adding TodorK to the answer.
What I did was, I initially set StreamVolume to Max and let the user control the SeekBar. As soon as they finished, I returned StreamVolume to its original state. This allows the user to manage the MediaPlayer volume and does not affect other applications.
First set Stream to your desired and initialize AudioManager
setVolumeControlStream(AudioManager.STREAM_MUSIC); audioManager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
Get InitialVolume (so you get it back after that) and set it to MaxVolume
final int initVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); final int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,maxVolume, 0);
Make an AudioStuff in the onProgress part of the SeekBarChangedListener
@Override public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) { float volume = (float) (1 - (Math.log(100 - progress) / Math.log(100))); mp.setVolume(volume, volume); mp.start(); }
Once you are done, return it to its original volume so that the user does not get angry (in my case im uses AlertDialog, so its in onDismiss thing
@Override public void onDismiss(DialogInterface dialog) { audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,initVolume, 0);
Also note that I did the magazine stuff in the onProgress part
source share