From dc36af19bc221813f66433a5f0922a56de579679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 20 Aug 2020 22:23:38 +0200 Subject: [PATCH] Detecting press on "stop screen sharing" --- front/src/WebRtc/MediaManager.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/front/src/WebRtc/MediaManager.ts b/front/src/WebRtc/MediaManager.ts index 635174be..63814ee4 100644 --- a/front/src/WebRtc/MediaManager.ts +++ b/front/src/WebRtc/MediaManager.ts @@ -186,6 +186,14 @@ export class MediaManager { return this._startScreenCapture() .then((stream: MediaStream) => { this.localScreenCapture = stream; + + // If stream ends (for instance if user clicks the stop screen sharing button in the browser), let's close the view + for (const track of stream.getTracks()) { + track.onended = () => { + this.disableScreenSharing(); + }; + } + return stream; }) .catch((err: unknown) => {