How Can I Get The Minimum Volume?
I know that code below is the max volume mAudioManager.getStreamMaxVolume how can i get the minimum volume? I used this code but not the minimum volume mAudioManager.getStreamVolu
Solution 1:
Try the following to reduce the volume of the music stream...
for (int volume = myAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) - 1; volume >= 0; volume--) {
//// add your delay code here//// Call a method to set absolute volumesetVolume(volume);
}
privatevoidsetVolume(int volume){
myAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0);
}
Solution 2:
A better approach to increase or decrease volume would be to use adjustVolume.
publicvoiddecreaseStreamVolume(int volType, AudioManager am){
am.adjustStreamVolume(volType, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI + AudioManager.FLAG_PLAY_SOUND);
}
You can enter AudioManager.STREAM_MUSIC or any desirable stream and AudioManager.ADJUST_LOWER or AudioManager.ADJUST_HIGHER as per your requirement. I believe it's much cleaner way to execute.
Post a Comment for "How Can I Get The Minimum Volume?"