我如何获得当前的音量/振幅在Android的MediaPlayer?振幅、音量、如何获得、MediaPlayer

由网友(枕头说它不想醒)分享简介:我工作的一个应用程序,都将录制的音频文件,然后有播放该文件一旦它被记录的选项。用户界面具有动画相对于记录的电流振幅均衡组件。我有动画通过MediaRecorder.getMaxAmplitude()方法的工作,但无法找到任何方式与MediaPlayer的做到这一点。我知道这一定是可能的,因为有默认的音乐可视化的动态壁纸...

我工作的一个应用程序,都将录制的音频文件,然后有播放该文件一旦它被记录的选项。用户界面具有动画相对于记录的电流振幅均衡组件。我有动画通过MediaRecorder.getMaxAmplitude()方法的工作,但无法找到任何方式与MediaPlayer的做到这一点。我知道这一定是可能的,因为有默认的音乐可视化的动态壁纸执行此功能,但我看不到任何方式,它是通过AOSP梳理拉时的信息。是否有人知道如何使这项工作?

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?

推荐答案

我认为你必须使用 AudioManager 。作为API指出它可用于音量控制:

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

AudioManager提供了访问量   和振铃模式控制。

AudioManager provides access to volume and ringer mode control.

使用   Context.getSystemService(Context.AUDIO_SERVICE)   得到这个类的一个实例。

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

其次,我认为this方法将是有益的。

Then I think this method would be useful.

阅读全文

相关推荐

最新文章