I am playing a beep sound for the last 5 seconds on a Timer.
I want to regulate the volume of the audio file with the volume keys of the mobile device.
I am currently using the android.media.SoundPool class to play the two audio files used for the Timer.
I am using the following method to play the sound:
public static void playSound(int index, float speed) {
float streamVolume = mAudioManager
.getStreamVolume(AudioManager.STREAM_MUSIC);
streamVolume = streamVolume
/ mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
mSoundPool.play(mSoundPoolMap.get(index), 1, 1,
1, 0, speed);
}
Currently I am able to play both the audio files but want to control with the mobile device volume keys.
Kindly provide your inputs/sample code.
Thanks in advance.