diff --git a/src/utils/webrtc/analyzers/ParticipantAnalyzer.js b/src/utils/webrtc/analyzers/ParticipantAnalyzer.js index 32ed3a059e3..a68411d688c 100644 --- a/src/utils/webrtc/analyzers/ParticipantAnalyzer.js +++ b/src/utils/webrtc/analyzers/ParticipantAnalyzer.js @@ -199,22 +199,26 @@ ParticipantAnalyzer.prototype = { }, _handlePeerChange: function(model, peer) { + if (this._peer) { + this._stopListeningToAudioVideoChanges() + } + this._peer = peer if (peer) { this._startListeningToAudioVideoChanges() - } else { - this._stopListeningToAudioVideoChanges() } }, _handleScreenPeerChange: function(model, screenPeer) { + if (this._screenPeer) { + this._stopListeningToScreenChanges() + } + this._screenPeer = screenPeer if (screenPeer) { this._startListeningToScreenChanges() - } else { - this._stopListeningToScreenChanges() } },