我如何获得当前的音量/振幅在Android的MediaPlayer? [英] How do I get the current volume/amplitude in an Android MediaPlayer?

查看:869
本文介绍了我如何获得当前的音量/振幅在Android的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.

其次,我认为<一href="http://developer.android.com/reference/android/media/AudioManager.html#getStreamVolume%28int%29">this方法将是有益的。

Then I think this method would be useful.

这篇关于我如何获得当前的音量/振幅在Android的MediaPlayer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆