0
我試過了stackoverflow.com上找到的所有方法,這個均衡器實例根本不會迴應。 我只是想讓它做非常基本的東西!無法使均衡器工作!它只是不會做任何事
我在16
我測試上的Galaxy S6我分項目API級別(安卓5.1.1 API 22)
// create : media player + equalizer
private void init() {
Log.d(TAG, "initMediaPlayer: ");
try {
mediaPlayer = new MediaPlayer();
equalizer = new Equalizer(0, mediaPlayer.getAudioSessionId());
if (equalizer.setEnabled(true) != Equalizer.SUCCESS) {
Log.d(TAG, "initMediaPlayer: FAILED");
return;
}
equalizer.usePreset((short) 0);
} catch (Exception e) {
Log.e(TAG, "initMediaPlayer: ", e);
}
}
// use next preset
private void useNextPreset() {
short presetCount = equalizer.getNumberOfPresets();
short index = equalizer.getCurrentPreset();
index++;
if (index >= presetCount) index = 0;
equalizer.usePreset(index);
Log.d(TAG, "useNextPreset: " + equalizer.getPresetName(index));
}
// show music picker
private void popPicker() {
popActivity(FilePickerIntent("audio/*"), new IntentRequestResultForward() {
@Override
public void onResult(boolean ok, Intent data) {
if (ok) play(data.getData());
}
});
}
// play music from uri
private void play(Uri uri) {
mediaPlayer.reset();
try {
mediaPlayer.setDataSource(getApplicationContext(), uri);
mediaPlayer.prepare();
mediaPlayer.start();
Log.d(TAG, "play: playing...");
} catch (Exception e) {
Log.e(TAG, "play: error ", e);
}
}
源代碼zip文件已損壞。 –
不只是檢查他們沒有。 –
對我來說它顯示「加載存檔時發生錯誤」 –