tags:

views:

326

answers:

2

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?

A: 

I think you have to use AudioManager. As the API states it can be used for volume control:

AudioManager provides access to volume and ringer mode control.

Use Context.getSystemService(Context.AUDIO_SERVICE) to get an instance of this class.

Then I think this method would be useful.

Roflcoptr
That's where I was poking around but that method returns the currently set volume level of the device, not the playback level.
Scott Ferguson
Where is the difference? Maybe you are asking for the volume of the wrong stream?
Janusz
A: 

I've been looking for a way to do something similar for a while. I really want to be able to see the volume/amplitude of anything being played over the media stream, but I'll settle for being able to do it for something I'm currently playing.

So far, the best solution I've found is implemented in RingDroid. I haven't looked into the code too deeply, but it looks like the way that RingDroid creates its soundmap is by actually analyzing the sound file bit by bit.

I've considered using a similar approach and then displaying a visualizer that runs separate from the audio file, but runs at a synchronized pace. However, this seems like too much work for something that should be way simpler.

HenryAdamsJr