Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close App at second time that I try to record! #4

Closed
magobin opened this issue Jan 16, 2018 · 1 comment
Closed

Close App at second time that I try to record! #4

magobin opened this issue Jan 16, 2018 · 1 comment

Comments

@magobin
Copy link

magobin commented Jan 16, 2018

Hi,thanks for your library.It's very useful for me, but I have a problem.Every time (not the first )I try to record audio....the app crashes.
Below the error:
01-16 14:31:23.668 897-897/com.example.alex.navdemo A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x20 in tid 897 (le.alex.navdemo) [ 01-16 14:31:23.669 453: 453 W/ debuggerd: handling request: pid=897 uid=10171 gid=10171 tid=897
Could You point me in the right way to get start to use your library ???
Thanks in advance !!
Alex
this is my code:

` recordView.setOnRecordListener(new OnRecordListener() {
@OverRide
public void onStart() {
//Start Recording..
try {
start();
} catch (IOException e) {
e.printStackTrace();
}
Log.d("RecordView", "onStart");
}
@OverRide
public void onCancel() {
//On Swipe To Cancel
try {
stop();
} catch (IOException e) {
e.printStackTrace();
}
Log.d("RecordView", "onCancel");

        }
                    @Override
                    public void onFinish(long recordTime) {
                    //Stop Recording..
                     try {
                    stop();
                    } catch (IOException e) {
                    e.printStackTrace();
                    }
        //   String time = recordButton.getHumanTimeText(recordTime);
        Log.d("RecordView", "onFinish");

         //   Log.d("RecordTime", time);
        }
   @Override
        public void onLessThanSecond() {
            //When the record time is less than One Second
            Log.d("RecordView", "onLessThanSecond");
        }
    });
    
    recordButton.setListenForRecord(true);`
public void start() throws IOException {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
    String currentDateandTime = sdf.format(new Date());
    String sd = Environment.getExternalStorageDirectory().toString()+
    File.separator + Environment.DIRECTORY_DOWNLOADS+
    File.separator +"testAudio"+ currentDateandTime +".3gpp";
    recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    recorder.setOutputFile(sd);
    recorder.prepare();
    recorder.start();
}

public void stop() throws IOException {
    recorder.stop();
    recorder.release();
}
@3llomi
Copy link
Owner

3llomi commented Jan 17, 2018

Hey @magobin
just move this code recorder = new MediaRecorder(); from onCreate() to inside your start() method

feel free to reopen this issue if you still have any issues

@3llomi 3llomi closed this as completed Jan 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants