0

Possible Duplicate:
How to control media volume?

Im making a game and when it starts i play music through this: ourSong = MediaPlayer.create(GameMenu.this, com.saad.batman.R.raw.fire );

    SharedPreferences getPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    boolean music = getPrefs.getBoolean("checkbox", true);
    if (music == true){
        ourSong.start();
    }

now what i want to do is that when i go to options from the Game Menu i want to be able to increase or decrease the music volume there. How do i do that?

Community
  • 1
  • 1

1 Answers1

0

If you use volume button then you don't need to do anything? just use it.

To set it in a game menu, add something like a spinner to slider in the menu. Get the setting value from them, and pass into the setVolume method.

mpVolumn are float numbers, for left and right.

Note that mpVolumn must be smaller than 1, so set the max like 0.99 or something

mediaPlayer.setVolume(mpVolumn, mpVolumn);

fangmobile
  • 839
  • 8
  • 23