From 75cb15ee12f8eb74584cf4b6f0d3afe7ea79177d Mon Sep 17 00:00:00 2001 From: Martin Schleyer Date: Sat, 6 Oct 2018 13:34:27 +0200 Subject: [PATCH] new fix for #107 ? --- openvidu-browser/src/OpenVidu/Stream.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/openvidu-browser/src/OpenVidu/Stream.ts b/openvidu-browser/src/OpenVidu/Stream.ts index b3671ec48c..fdac382fa5 100644 --- a/openvidu-browser/src/OpenVidu/Stream.ts +++ b/openvidu-browser/src/OpenVidu/Stream.ts @@ -447,12 +447,17 @@ export class Stream implements EventDispatcher { */ disposeMediaStream(): void { if (this.mediaStream) { - this.mediaStream.getAudioTracks().forEach((track) => { - track.stop(); - }); - this.mediaStream.getVideoTracks().forEach((track) => { - track.stop(); - }); + const isSenderAndCustomTrack: boolean = !!this.outboundStreamOpts && + this.outboundStreamOpts.publisherProperties.videoSource instanceof MediaStreamTrack; + + if (!isSenderAndCustomTrack) { + this.mediaStream.getAudioTracks().forEach((track) => { + track.stop(); + }); + this.mediaStream.getVideoTracks().forEach((track) => { + track.stop(); + }); + } delete this.mediaStream; } console.info((!!this.outboundStreamOpts ? 'Local ' : 'Remote ') + "MediaStream from 'Stream' with id [" + this.streamId + '] is now disposed');