programatically change volume

gorelshv

Member
Licensed User
Longtime User
Please add an option to change the volume of currently playing media. This is very important for alarm apps. Here is a code snippet i found here: Dealing with the Android Media Player Think Android

B4X:
AudioManager mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
int maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, maxVolume, AudioManager.FLAG_PLAY_SOUND);

// or
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, maxVolume, AudioManager.FLAG_SHOW_UI);

// or
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, maxVolume, AudioManager.FLAG_VIBRATE);

// etc
Thanks.
 

gorelshv

Member
Licensed User
Longtime User
Actually, no. I'm using Soundpool in the audio library and it doesn't effect the system volume.
 

gorelshv

Member
Licensed User
Longtime User
I know, but it seems to affect the stream only "localy". What I'm trying to do is to make an alarm that will set the volume of the speaker to the max and then play the alarm. That way, the user won't have to set the volume manually before setting up the alarm. The play method seems to affect the stream but not the system. It's like setting the "wave" volume at max but leaving "master" volume low on a pc.
 
Top