From 7cb73a501f0fdaa565fa615e5d2f603d8d8f9242 Mon Sep 17 00:00:00 2001 From: Alain Takoudjou Date: Fri, 6 Nov 2020 10:03:33 +0100 Subject: [PATCH] do not listen on camera control button when it's not present --- static/sfu.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/static/sfu.js b/static/sfu.js index 4dd51d6..b763b03 100644 --- a/static/sfu.js +++ b/static/sfu.js @@ -1092,22 +1092,25 @@ function registerControlEvent(peerid) { } }; - peer.querySelector("span.camera").onclick = function(event) { - event.preventDefault(); - let video = getParentVideo(event.target); - let id = video.id.split("-")[1]; - if (!settings.video) - return; - if (event.target.getAttribute("data-type") === "bt-camera") { - addLocalMedia(id, true); - event.target.setAttribute("data-type", "bt-camera-off"); - event.target.parentElement.classList.add("disabled"); - } else { - event.target.setAttribute("data-type", "bt-camera"); - event.target.parentElement.classList.remove("disabled"); - addLocalMedia(id); - } - }; + let camera = peer.querySelector("span.camera"); + if (camera) { + peer.querySelector("span.camera").onclick = function(event) { + event.preventDefault(); + let video = getParentVideo(event.target); + let id = video.id.split("-")[1]; + if (!settings.video) + return; + if (event.target.getAttribute("data-type") === "bt-camera") { + addLocalMedia(id, true); + event.target.setAttribute("data-type", "bt-camera-off"); + event.target.parentElement.classList.add("disabled"); + } else { + event.target.setAttribute("data-type", "bt-camera"); + event.target.parentElement.classList.remove("disabled"); + addLocalMedia(id); + } + }; + } }