I'm working on an app that will both record an audio file, and then have the option to play back that file once it's been recorded. The UI has an EQ component that animates relative to the current amplitude of the recording. I've got the animation working via the MediaRecorder.getMaxAmplitude()
method, but can't find any means to do this with MediaPlayer. I know it must be possible since there are music visualization Live Wallpapers by default that perform this functionality but I can't see any way that it's pulling that information when combing through AOSP. Does anybody know how to make this work?
You can get the current volume of media player with the help of Audiomanager class.The code is as follows:-
AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE); int volume_level= am.getStreamVolume(AudioManager.STREAM_MUSIC);
Similarly,if you want to set the default volume of media player.You can do that like as:-
am.setStreamVolume( AudioManager.STREAM_MUSIC, volume_level, 0);
That's all..Happy coding :)
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