From 20c6dc618f0c546938eae4aa6428458e662c9601 Mon Sep 17 00:00:00 2001 From: Usman Date: Fri, 15 Apr 2022 15:47:51 +0500 Subject: [PATCH] fix: #142 --- src/app/modules/webcam/webcam/webcam.component.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/modules/webcam/webcam/webcam.component.ts b/src/app/modules/webcam/webcam/webcam.component.ts index ad498ad..963c4e5 100644 --- a/src/app/modules/webcam/webcam/webcam.component.ts +++ b/src/app/modules/webcam/webcam/webcam.component.ts @@ -199,6 +199,7 @@ export class WebcamComponent implements AfterViewInit, OnDestroy { public ngOnDestroy(): void { this.stopMediaTracks(); this.unsubscribeFromSubscriptions(); + this.mediaStream = null; } /** @@ -395,7 +396,10 @@ export class WebcamComponent implements AfterViewInit, OnDestroy { // getTracks() returns all media tracks (video+audio) this.mediaStream.getTracks() - .forEach((track: MediaStreamTrack) => track.stop()); + .forEach((track: MediaStreamTrack) => { + track.stop(); + this.mediaStream.removeTrack(track); + }); } }