FireZenk / AudioWaves

Shows a graphic representation of the sounds captured by the microphone on Android
817 stars 154 forks source link

How to use your library when recording audio using mic? #9

Open Gaket opened 8 years ago

Gaket commented 8 years ago

Hello!

Thank you for sharing your work!

I am struggling to make it work in parallel with audio recording. I get MediaRecorder IllegalState exception again and again.

I am using your visualiser this way:

 private void startRecording() {
        mRecorder = new MediaRecorder();
        mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
        mRecorder.setOutputFile(mFileName);
        mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_WB);

        try {
            mRecorder.prepare();
        } catch (IOException e) {
            Timber.e("prepare() failed");
        }
       mRecorder.start();
       mVisualizer.startListening();
    }

    private void stopRecording() {
        mVisualizer.stopListening();
        mRecorder.stop();
        mRecorder.release();
        mRecorder = null;
    }

What do I do wrong?

liuzhen2008 commented 7 years ago

@Gaket have you resolved the issue yet? I ran into the same issue.

Gaket commented 7 years ago

@liuzhen2008, unfortunately, not. Now I am using just static image. Tell me please if you solve the problem.