From 481ed05715f43f5fbe3b95c8808d5dff784e2ee6 Mon Sep 17 00:00:00 2001 From: Rushikesh Satpute <65356859+Rushikesh-Satpute@users.noreply.github.com> Date: Thu, 1 Oct 2020 12:29:41 +0530 Subject: [PATCH 1/2] Update AudioRecording.java --- .../br/com/safety/audio_recorder/AudioRecording.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/audio-recorder/src/main/java/br/com/safety/audio_recorder/AudioRecording.java b/audio-recorder/src/main/java/br/com/safety/audio_recorder/AudioRecording.java index 485509a..c9503eb 100644 --- a/audio-recorder/src/main/java/br/com/safety/audio_recorder/AudioRecording.java +++ b/audio-recorder/src/main/java/br/com/safety/audio_recorder/AudioRecording.java @@ -85,6 +85,15 @@ private void deleteOutput() { } } + public void stopRecording(int time) { + // This method can apply timer limit for recording + new Handler().postDelayed(new Runnable() { + public void run() { + stop(false); + } + }, time); + } + public void play(RecordingItem recordingItem) { try { this.mMediaPlayer = new MediaPlayer(); From 98b77036196bf851464dd2881cc337e78bff1797 Mon Sep 17 00:00:00 2001 From: Rushikesh Satpute <65356859+Rushikesh-Satpute@users.noreply.github.com> Date: Thu, 1 Oct 2020 12:34:40 +0530 Subject: [PATCH 2/2] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 3b83be2..1040c3d 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,13 @@ audioRecordButton.setOnAudioListener(new AudioListener() { }); ``` +Stop audio Recording after specific time + +``` +// After Initilizing audio recorder, this can stop recording after 1 min. +StopRecording(60000); +``` + If you prefer to execute the sound after the audio capture, just call the `play()` method inside `onStop()` ```java