Я использую AudioManager для записи аудио.
Итак, всякий раз, когда я пытаюсь установить высоту тона, используя функцию setPitch, мое приложение вылетает.
Примечание: samplerate = 8500
Вот код
buttonPlayLastRecordAudio.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) throws IllegalArgumentException,
SecurityException, IllegalStateException {
buttonStop.setEnabled(false);
buttonStart.setEnabled(false);
buttonStopPlayingRecording.setEnabled(true);
mediaPlayer = new MediaPlayer();
try {
mediaPlayer.setDataSource(AudioSavePathInDevice);
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
params.setPitch(samplerate);
mediaPlayer.setPlaybackParams(params);
mediaPlayer.start();
Toast.makeText(MainActivity.this, "Recording Playing",
Toast.LENGTH_LONG).show();
}
});
А вот и ошибка
2020-02-20 18:43:33.574 9544-9577/com.mycompany.testaudio E/MemoryLeakMonitorManager: MemoryLeakMonitor.jar is not exist!
2020-02-20 18:43:33.587 9544-9592/com.mycompany.testaudio E/AwareLog: AtomicFileUtils: readFileLines file not exist: android.util.AtomicFile@f96188d
2020-02-20 18:43:37.561 9544-9544/com.mycompany.testaudio E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mycompany.testaudio, PID: 9544
java.lang.IllegalArgumentException
at android.media.MediaPlayer.setPlaybackParams(Native Method)
at com.mycompany.testaudio.MainActivity$3.onClick(MainActivity.java:162)
at android.view.View.performClick(View.java:6659)
at android.view.View.performClickInternal(View.java:6631)
at android.view.View.access$3100(View.java:790)
at android.view.View$PerformClick.run(View.java:26187)
at android.os.Handler.handleCallback(Handler.java:907)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)