I created a simple application.
In my main activity class i use this to play a sound when a button is clicked
MediaPlayer buttonSound = MediaPlayer.create(this, R.drawable.button_sound);
public void onClick(View arg0){
buttonSound.start();
}
In my main activity class i have a service that start a background music
Intent svc=new Intent(this, BackgroundSoundService.class);
startService(svc);
The problem is that I can’t handle them (my background music and my button sound) with the volume buttons of my mobile.
If i decrease the volume of my mobile, my application volume doesn’t change!
what should I do?
You can use AudioManager to control volumn of Media Player.
Also can use setVolume (float leftVolume, float rightVolume) for your media player as like as
Where
Parameters
leftVolume–> left volume scalar
rightVolume–> right volume scalar