I am writing an app that in some situations warns user with an alarm sound. My problem is that in some situation volume of media playing may be decreased by user or even media volume is silent. I want to check the volume programatically and increase it to 100% and then play alarm.
Any idea? Note that I have tested mediaPlayer.setVolume(1,1)
and nothing changed.
This isn't the function for setting the volume. Here it's the setting of the volume to any value:
AudioManager audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
// For example to set the volume of played media to maximum.
audioManager.setStreamVolume (AudioManager.STREAM_MUSIC, audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC),0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With