diff --git a/library/src/main/java/tech/oom/idealrecorder/IdealRecorder.java b/library/src/main/java/tech/oom/idealrecorder/IdealRecorder.java index 290983d..558c5e3 100644 --- a/library/src/main/java/tech/oom/idealrecorder/IdealRecorder.java +++ b/library/src/main/java/tech/oom/idealrecorder/IdealRecorder.java @@ -9,6 +9,7 @@ import android.support.v4.content.ContextCompat; import android.text.TextUtils; +import java.io.ByteArrayOutputStream; import java.util.concurrent.atomic.AtomicBoolean; import tech.oom.idealrecorder.file.AudioFileHelper; @@ -35,7 +36,7 @@ public class IdealRecorder implements RecorderCallback, AudioFileListener { private long maxRecordTime = 6000L; private long volumeInterval = 200L; private int count; - + private ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); private AtomicBoolean isStarted = new AtomicBoolean(false); private IdealRecorder() { @@ -213,6 +214,7 @@ public boolean onRecorderStart() { audioFileHelper.start(); } count = 0; + byteArrayOutputStream.reset(); runOnUi(new Runnable() { public void run() { if (statusListener != null) { @@ -232,7 +234,7 @@ public void onRecorded(final short[] wave) { audioFileHelper.save(bytes, 0, bytes.length); } - + byteArrayOutputStream.write(bytes, 0, bytes.length); runOnUi(new Runnable() { @Override public void run() { @@ -304,10 +306,12 @@ public void onRecorderStop() { @Override public void run() { if (statusListener != null) { + statusListener.onRecordedAllData(byteArrayOutputStream.toByteArray()); statusListener.onStopRecording(); } } }); +// byteArrayOutputStream.reset(); } private int calculateVolume(short[] wave) { diff --git a/library/src/main/java/tech/oom/idealrecorder/StatusListener.java b/library/src/main/java/tech/oom/idealrecorder/StatusListener.java index 8f6b044..1853b3d 100644 --- a/library/src/main/java/tech/oom/idealrecorder/StatusListener.java +++ b/library/src/main/java/tech/oom/idealrecorder/StatusListener.java @@ -32,7 +32,6 @@ public void onVoiceVolume(int volume) { } - /** * 录音失败 * @@ -69,4 +68,13 @@ public void onFileSaveSuccess(String fileUri) { public void onStopRecording() { } + /** + * 全部的录音pcm数据 + * + * @param arr 所有的录音pcm数据 + */ + public void onRecordedAllData(byte[] arr) { + + } + }