录音和内存不足异常
作者:互联网
你好
我有音频记录,我使用mediarecorder类录制音频,但是当我达到2 m时,内存不足,这是我的极限.我在下面给出了我的代码.
时间
私有静态无效audiorecding()
{
如果(audio_recding_stop_flag == 0){
audio_recding_stop_flag = 1;
recorder.stop();
recorder.reset();
recorder.release();
recorder=new MediaRecorder();
int maxtime = audio_seekbar_play_indication.getMax();
audio_seekbar_progress = 0;
audio_seekbar_incr = maxtime/ AngiesData.gettotalaudiorecdingtimeinseconds(audio_recding_time.getText().toString());
audio_recding_time.stop();
recd_stop_audio.setBackgroundResource(R.drawable.rec_btn);
audio_play_pause.setEnabled(true);
delete_recding.setEnabled(true);
AngiesData.angiesListContext.setAudioRecd(true);
AngiesData.angiesListContext.setAudioRecdingTime((String) audio_recding_time.getText());
}
else {
audio_recding_stop_flag = 0;
try {
audio_play_pause.setEnabled(false);
delete_recding.setEnabled(false);
recd_stop_audio.setBackgroundResource(R.drawable.recording_stop);
audio_recding_time .setBase(SystemClock.elapsedRealtime());
audio_recding_time.start();
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC); // AudioSource
recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT); // OutputFormat
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
path = InitialValueLoader.sanitizePath("Audio/VoiceReport");
InitialValueLoader.filecheck(path);
recorder.setOutputFile(path);
recorder.setMaxDuration(120000);
recorder.prepare();
recorder.start();
} catch (Exception e) {
e.printStackTrace();
}
}
解决方法:
我建议使用计时器而不是计时器
标签:out-of-memory,android 来源: https://codeday.me/bug/20191209/2095603.html