0

My Android app plays audio, even when other music is being played by device or some other app.

I want to take user input from SeekBar & set my app’s volume in background, as percentage to the current device music volume.I want to set my Android app’s volume as ‘n%’ of device volume at any time, ‘n’ being the value of SeekBar in the app.

I tried doing this:

volumeSeekbar.setMax(100); @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { progress = (progress * (myAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC)))/100; myAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, progress, 0); }

But above code will change overall device volume. In my case, I want device music to be uninterrupted & retain its volume.

Let’s say if device music is being played at volume 80, and user sets app’s Seekbar to 50, then app audio should be played at volume 50%(80) = 40. In this case both the audios will be played, device volume being retained at 80 & app volume as 50% of 80. If device volume or SeekBar value changes at any time, app volume should also change.

How to achieve this?

San
  • 1
  • 3

1 Answers1

2

The only volume settings are the ones from the device system settings. The application-specific volume settings is not supported by the Android OS currently and there is no way that you can control volume in application independently of device volume.

skyrideraj
  • 71
  • 5
  • Ohh I see! Can we have another approach here.. Can we normalize or tone down the app audio to lower the volume by certain percentage in real time? How to implement this? – San Jan 04 '16 at 14:37
  • I tried this Android app "DJStudio 5".. In this app I am able to set app audio the way required in question.. so **this is possible!!**.. question is how to do it? – San Jan 04 '16 at 16:17