From e20fe6d4add6851b5792a715389af33014ee3cef Mon Sep 17 00:00:00 2001
From: prlanzarin <4529051+prlanzarin@users.noreply.github.com>
Date: Fri, 23 Jul 2021 02:27:02 +0000
Subject: [PATCH] fix(screenshare): avoid leaving a dangling HTMLMediaElement
 in paused state

---
 .../imports/api/screenshare/client/bridge/kurento.js      | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/bigbluebutton-html5/imports/api/screenshare/client/bridge/kurento.js b/bigbluebutton-html5/imports/api/screenshare/client/bridge/kurento.js
index d630056067..42ee92cbd5 100755
--- a/bigbluebutton-html5/imports/api/screenshare/client/bridge/kurento.js
+++ b/bigbluebutton-html5/imports/api/screenshare/client/bridge/kurento.js
@@ -283,6 +283,8 @@ export default class KurentoScreenshareBridge {
   };
 
   stop() {
+    const mediaElement = document.getElementById(SCREENSHARE_VIDEO_TAG);
+
     if (this.broker) {
       this.broker.stop();
       // Checks if this session is a sharer and if it's not reconnecting
@@ -292,6 +294,12 @@ export default class KurentoScreenshareBridge {
       if (this.broker.role === SEND_ROLE && !this.reconnecting) setSharingScreen(false);
       this.broker = null;
     }
+
+    if (mediaElement && typeof mediaElement.pause === 'function') {
+      mediaElement.pause();
+      mediaElement.srcObject = null;
+    }
+
     this.gdmStream = null;
     this.clearReconnectionTimeout();
   }
-- 
GitLab