我正在尝试创建一个可以接收音频并使用混响播放的应用。这是我的代码。我用谷歌搜索了几个小时,但未能解决问题。音乐正在播放但没有添加任何混响。我正在使用Acer Iconia A1来测试应用程序。
非常感谢任何帮助。谢谢。
public class Eq extends Activity {
String filePath;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
filePath = Environment.getExternalStorageDirectory().getAbsolutePath()
+ "/y.mp3";
playSound();
}
public void playSound() {
final MediaPlayer player = new MediaPlayer();
try {
player.setDataSource(this, Uri.parse(filePath));
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
PresetReverb mReverb = new PresetReverb(1, 0);
mReverb.setPreset(PresetReverb.PRESET_LARGEROOM);
mReverb.setEnabled(true);
player.attachAuxEffect(mReverb.getId());
player.setAuxEffectSendLevel(1.0f);
// prepare for playback
try {
player.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
player.start();
}
}