Używam MediaRecorder do nagrywania ale metoda start blokuje mi całe UI. Pytanie czy coś nie robię źle?
MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
//recorder.setOutputFile(parcelWrite.getFileDescriptor());
recorder.setOutputFile(tempAudioFile.getPath());
recorder.prepare();
recorder.start();
Tak samo MediaPlayer.start() blokuje na stałe UI
try {
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(tempAudioFile.getPath());
mediaPlayer.setLooping(false);
mediaPlayer.start();
} catch (IOException ex) {
ex.printStackTrace();
}
Czy powinienem uruchomić to w osobnym wątku?