Exclude audio and from memory

Hi, I have a sound recording in mine. I use the mediarecorder class to listen to the sound again, but I have a memory exception when I reach 2 meters, this is my limit. I gave my code below.

time

private static void audiorecding () {if (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();
        }   
}
+3
source share
3 answers

I suggest using a chronometer instead of a timer

+1
source

- AudioRecord-Class (http://developer.android.com/reference/android/media/AudioRecord.html), read() while-loop , 2 . ( , , 44,1 Khz = > 44100 / = > 60 * 44100 /). , 2 . - . , , , , , .

+2

, , . , , 120000 .

0

Source: https://habr.com/ru/post/1774254/


All Articles