Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set volume to max in Android [duplicate]

Tags:

android

audio

In my app, I am trying to set the volume when playing an audio clip to the maximum level but it doesn't appear to have any affect. I have to manually adjust the volume to the maximum level. Here's my code:

MediaPlayer mp = new MediaPlayer();
mp.setVolume(1, 1);
like image 956
Johann Avatar asked Apr 26 '13 05:04

Johann


People also ask

How do I limit maximum volume on Android?

From Settings, choose Sounds and vibration and Volume, then tap the three dots (top right) and choose Media volume limit.


Video Answer


1 Answers

AudioManager

int origionalVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC), 0);
like image 92
Nirav Ranpara Avatar answered Sep 24 '22 21:09

Nirav Ranpara