diff --git a/openvidu-browser/src/OpenVidu/Stream.ts b/openvidu-browser/src/OpenVidu/Stream.ts index dd3ee33f..506347cd 100644 --- a/openvidu-browser/src/OpenVidu/Stream.ts +++ b/openvidu-browser/src/OpenVidu/Stream.ts @@ -452,12 +452,12 @@ export class Stream implements EventDispatcher { * @hidden */ disposeWebRtcPeer(): void { - if (this.webRtcPeer) { + if (!!this.webRtcPeer) { const isSenderAndCustomTrack: boolean = !!this.outboundStreamOpts && typeof MediaStreamTrack !== 'undefined' && this.outboundStreamOpts.publisherProperties.videoSource instanceof MediaStreamTrack; this.webRtcPeer.dispose(isSenderAndCustomTrack); } - if (this.speechEvent) { + if (!!this.speechEvent && !!this.speechEvent.stop) { this.speechEvent.stop(); delete this.speechEvent; }