From 124e49947c946a8af6cef36a3a076f1ee3225b33 Mon Sep 17 00:00:00 2001 From: Ian Ramzy Date: Fri, 3 Apr 2020 00:05:14 -0400 Subject: [PATCH] auto swap back to webcam after screen share --- public/js/chat.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public/js/chat.js b/public/js/chat.js index e9e9b33..505d1d6 100644 --- a/public/js/chat.js +++ b/public/js/chat.js @@ -493,7 +493,7 @@ function swap() { navigator.mediaDevices .getDisplayMedia({ video: true, - audio: true, + audio: false, }) .then(function (stream) { mode = "screen"; @@ -524,6 +524,9 @@ function swap() { function switchStreamHelper(stream) { let videoTrack = stream.getVideoTracks()[0]; + videoTrack.onended = function () { + swap(); + }; if (VideoChat.connected) { const sender = VideoChat.peerConnection.getSenders().find(function (s) { return s.track.kind === videoTrack.kind;