_setIsMicMuted()

in lex-web-ui/src/lib/lex/recorder.js [357:383]


  _setIsMicMuted() {
    if (!this.useAutoMuteDetect) {
      return;
    }
    // TODO incorporate _maxVolume
    if (this._instant >= this.muteThreshold) {
      if (this._isMicMuted) {
        this._isMicMuted = false;
        this._eventTarget.dispatchEvent(new Event('unmute'));
      }
      return;
    }

    if (!this._isMicMuted && (this._slow < this.muteThreshold)) {
      this._isMicMuted = true;
      this._eventTarget.dispatchEvent(new Event('mute'));
      console.info(
        'mute - instant: %s - slow: %s - track muted: %s',
        this._instant, this._slow, this._tracks[0].muted,
      );

      if (this._state === 'recording') {
        this.stop();
        console.info('stopped recording on _setIsMicMuted');
      }
    }
  }