@stream-io/video-client 1.0.8 → 1.0.9

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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ### [1.0.9](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.0.8...@stream-io/video-client-1.0.9) (2024-05-29)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * prevent double sound detectors set up ([#1371](https://github.com/GetStream/stream-video-js/issues/1371)) ([51c9198](https://github.com/GetStream/stream-video-js/commit/51c9198a96b956884554bc508e38c90af0cee30f))
11
+
5
12
  ### [1.0.8](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.0.7...@stream-io/video-client-1.0.8) (2024-05-23)
6
13
 
7
14
 
@@ -11904,39 +11904,43 @@ class MicrophoneManager extends InputMediaDeviceManager {
11904
11904
  return this.call.stopPublish(TrackType.AUDIO, stopTracks);
11905
11905
  }
11906
11906
  async startSpeakingWhileMutedDetection(deviceId) {
11907
- await this.stopSpeakingWhileMutedDetection();
11908
- if (isReactNative()) {
11909
- this.rnSpeechDetector = new RNSpeechDetector();
11910
- await this.rnSpeechDetector.start();
11911
- const unsubscribe = this.rnSpeechDetector?.onSpeakingDetectedStateChange((event) => {
11912
- this.state.setSpeakingWhileMuted(event.isSoundDetected);
11913
- });
11914
- this.soundDetectorCleanup = () => {
11915
- unsubscribe();
11916
- this.rnSpeechDetector?.stop();
11917
- this.rnSpeechDetector = undefined;
11918
- };
11919
- }
11920
- else {
11921
- // Need to start a new stream that's not connected to publisher
11922
- const stream = await this.getStream({
11923
- deviceId,
11924
- });
11925
- this.soundDetectorCleanup = createSoundDetector(stream, (event) => {
11926
- this.state.setSpeakingWhileMuted(event.isSoundDetected);
11927
- });
11928
- }
11907
+ const startPromise = (async () => {
11908
+ await this.stopSpeakingWhileMutedDetection();
11909
+ if (isReactNative()) {
11910
+ this.rnSpeechDetector = new RNSpeechDetector();
11911
+ await this.rnSpeechDetector.start();
11912
+ const unsubscribe = this.rnSpeechDetector?.onSpeakingDetectedStateChange((event) => {
11913
+ this.state.setSpeakingWhileMuted(event.isSoundDetected);
11914
+ });
11915
+ return () => {
11916
+ unsubscribe();
11917
+ this.rnSpeechDetector?.stop();
11918
+ this.rnSpeechDetector = undefined;
11919
+ };
11920
+ }
11921
+ else {
11922
+ // Need to start a new stream that's not connected to publisher
11923
+ const stream = await this.getStream({
11924
+ deviceId,
11925
+ });
11926
+ return createSoundDetector(stream, (event) => {
11927
+ this.state.setSpeakingWhileMuted(event.isSoundDetected);
11928
+ });
11929
+ }
11930
+ })();
11931
+ this.soundDetectorCleanup = async () => {
11932
+ const cleanup = await startPromise;
11933
+ await cleanup();
11934
+ };
11935
+ await startPromise;
11929
11936
  }
11930
11937
  async stopSpeakingWhileMutedDetection() {
11931
11938
  if (!this.soundDetectorCleanup)
11932
11939
  return;
11940
+ const soundDetectorCleanup = this.soundDetectorCleanup;
11941
+ this.soundDetectorCleanup = undefined;
11933
11942
  this.state.setSpeakingWhileMuted(false);
11934
- try {
11935
- await this.soundDetectorCleanup();
11936
- }
11937
- finally {
11938
- this.soundDetectorCleanup = undefined;
11939
- }
11943
+ await soundDetectorCleanup();
11940
11944
  }
11941
11945
  }
11942
11946
 
@@ -15265,7 +15269,7 @@ class StreamClient {
15265
15269
  });
15266
15270
  };
15267
15271
  this.getUserAgent = () => {
15268
- const version = "1.0.8" ;
15272
+ const version = "1.0.9" ;
15269
15273
  return (this.userAgent ||
15270
15274
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
15271
15275
  };