我不知道我能做些什么来解决这些问题。我正在实现一个 MediaPlayer + Equalizer 应用程序。我的 MediaPlayer 工作正常,但是,我的均衡器有问题:它的某些方法不起作用。
public class MainActivity extends Activity {
private MediaPlayer mediaPlayer;
private Equalizer equalizer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mediaPlayer = new MediaPlayer();
try {
mediaPlayer.setDataSource("/sdcard/titanium.mp3");
mediaPlayer.prepare();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mediaPlayer.start();
equalizer = new Equalizer(0, 0);
equalizer.setEnabled(true);
int minEQLevel = equalizer.getBandLevelRange()[0];
int maxEQLevel = equalizer.getBandLevelRange()[1];
Log.i("kkk", "Valor de minEQLevel" + minEQLevel);
Log.i("kkk", "Valor de maxEQLevel" + maxEQLevel);
short numberOfBand = equalizer.getNumberOfBands();
Log.i("kkk", "Número de bandas = "+numberOfBand);
/******From here to down the methods don't work *****/
try {
short band = equalizer.getBand(Integer.valueOf(50000));
Log.i("kkk", "getBand() = "+band);
short band = 0;
//int menor = equalizer.getBandFreqRange(band)[0];
//int maior = equalizer.getBandFreqRange(band)[1];
//Log.i("kkk", "Menor = "+menor);
//Log.i("kkk", "Maior = "+maior);
} catch (IllegalArgumentException e) {
Log.i("kkk", "Bad parameter value");
} catch (UnsupportedOperationException e) {
Log.i("kkk", "get parameter() rejected");
} catch (IllegalStateException e) {
Log.i("kkk", "get parameter() called in wrong state");
}
}
}
以下方法正常工作: getBandLevelRange(); getNumberOfBands();
以下方法不起作用。我收到消息错误:参数值错误。获取带();getBandFreqRange(); 最后一个被评论,但当它不是也不起作用时。
在 getBand() 方法中,我已经尝试了几个参数值,例如:50000、1000000。AudioFx 库示例中支持的频率。
为什么这些方法不起作用???我原谅设置什么了吗???
tks。