From 1f8aad013a44deb495585faddcb75cdbafc5e0cf Mon Sep 17 00:00:00 2001 From: Gennady Grishkovtsov Date: Thu, 2 May 2019 23:31:54 +0300 Subject: [PATCH] Remove context closing from "pause" action & minor improvoments --- src/lib/recorder.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/lib/recorder.js b/src/lib/recorder.js index aef86a2..9101539 100644 --- a/src/lib/recorder.js +++ b/src/lib/recorder.js @@ -7,8 +7,11 @@ export default class { this.pauseRecording = options.pauseRecording this.afterRecording = options.afterRecording this.micFailed = options.micFailed - this.bitRate = options.bitRate - this.sampleRate = options.sampleRate + + this.lameOptions = { + bitRate : options.bitRate, + sampleRate : options.sampleRate + } this.bufferSize = 4096 this.records = [] @@ -37,12 +40,13 @@ export default class { .getUserMedia(constraints) .then(this._micCaptured.bind(this)) .catch(this._micError.bind(this)) - this.isPause = false + + this.isPause = false this.isRecording = true - if (!this.lameEncoder) this.lameEncoder = new Encoder({ - bitRate : this.bitRate, - sampleRate : this.sampleRate - }) + + if (!this.lameEncoder) { + this.lameEncoder = new Encoder(this.lameOptions) + } } stop () { @@ -68,7 +72,6 @@ export default class { this.stream.getTracks().forEach((track) => track.stop()) this.input.disconnect() this.processor.disconnect() - this.context.close() this._duration = this.duration this.isPause = true