auto swap back to webcam after screen share

This commit is contained in:
Ian Ramzy 2020-04-03 00:05:14 -04:00
parent 4c8c7fd37b
commit 124e49947c

View File

@ -493,7 +493,7 @@ function swap() {
navigator.mediaDevices navigator.mediaDevices
.getDisplayMedia({ .getDisplayMedia({
video: true, video: true,
audio: true, audio: false,
}) })
.then(function (stream) { .then(function (stream) {
mode = "screen"; mode = "screen";
@ -524,6 +524,9 @@ function swap() {
function switchStreamHelper(stream) { function switchStreamHelper(stream) {
let videoTrack = stream.getVideoTracks()[0]; let videoTrack = stream.getVideoTracks()[0];
videoTrack.onended = function () {
swap();
};
if (VideoChat.connected) { if (VideoChat.connected) {
const sender = VideoChat.peerConnection.getSenders().find(function (s) { const sender = VideoChat.peerConnection.getSenders().find(function (s) {
return s.track.kind === videoTrack.kind; return s.track.kind === videoTrack.kind;