@innovastudio/contentbuilder 1.4.81 → 1.4.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbuilder",
3
3
  "type": "module",
4
- "version": "1.4.81",
4
+ "version": "1.4.82",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "files": [
@@ -77822,10 +77822,22 @@ class Dictation {
77822
77822
  stopDictation() {
77823
77823
  if (this.recognition) this.recognition.abort();
77824
77824
  this.aborted = true;
77825
- if (this.recorder) this.recorder.stopRecording();
77826
- if (this.localStream) this.localStream.getAudioTracks().forEach(track => {
77827
- track.stop();
77828
- });
77825
+
77826
+ // Using RecordRTC
77827
+ // if(this.recorder) this.recorder.stopRecording();
77828
+ // if(this.localStream) this.localStream.getAudioTracks().forEach(track => {
77829
+ // track.stop();
77830
+ // });
77831
+
77832
+ // Using mediaRecorder
77833
+ if (this.mediaRecorder && this.mediaRecorder.state !== 'inactive') {
77834
+ this.mediaRecorder.stop();
77835
+ this.localStream.getTracks().forEach(track => track.stop()); // Stop the tracks to release the resources
77836
+ }
77837
+
77838
+ if (this.websocket && this.websocket.readyState === WebSocket.OPEN) {
77839
+ this.websocket.close();
77840
+ }
77829
77841
  }
77830
77842
  async startDictation() {
77831
77843
  const inpCommand = this.modalCommand.querySelector('.inp-command');
@@ -77879,9 +77891,14 @@ class Dictation {
77879
77891
  sampleRate: sampleRate
77880
77892
  }
77881
77893
  }).then(stream => {
77894
+ this.localStream = stream;
77882
77895
  this.mediaRecorder = new MediaRecorder(stream);
77883
77896
  this.mediaRecorder.addEventListener('dataavailable', event => {
77897
+ if (this.aborted) return;
77898
+
77884
77899
  // console.log(event.data);
77900
+ // if (event.data.size > 0) {
77901
+ // }
77885
77902
  this.websocket.send(event.data);
77886
77903
  });
77887
77904