From 602eb62462cae2ef4201a3e0e6cdb1ac3d8510b1 Mon Sep 17 00:00:00 2001 From: Oliver Tacke Date: Thu, 24 Sep 2020 12:44:18 +0200 Subject: [PATCH] Fix closing of AudioContext that is already closed When you were retrying after being done, the 'retry' handler was trying to close the AudioContext that had already been closed by the 'done' handler thus throwing an exception. Fixed by checking the AudioContext's state for being closed already before trying to close it. --- src/components/Recorder.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Recorder.js b/src/components/Recorder.js index 8faed86..e0190e6 100644 --- a/src/components/Recorder.js +++ b/src/components/Recorder.js @@ -248,7 +248,9 @@ export default class Recorder extends H5P.EventDispatcher { this.stream.getAudioTracks().forEach(track => track.stop()); this.sourceNode.disconnect(); this.scriptProcessorNode.disconnect(); - this.audioContext.close(); + if (this.audioContext.state !== 'closed') { + this.audioContext.close(); + } delete this.userMedia; }