From 85df898101cba4944e605e4a966428164f595775 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Mon, 9 Nov 2020 00:35:52 +0100 Subject: [PATCH] Remove PIP button when not supported. --- static/sfu.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/static/sfu.js b/static/sfu.js index 49eaa94..48b8292 100644 --- a/static/sfu.js +++ b/static/sfu.js @@ -1090,11 +1090,17 @@ function registerControlEvent(peerid) { } }; - peer.querySelector("span.pip").onclick = function(event) { - event.preventDefault(); - let video = getParentVideo(event.target); - videoPIP(video); - }; + let pip = /** @type {HTMLElement} */(peer.querySelector("span.pip")); + /** @ts-ignore */ + if(HTMLVideoElement.prototype.requestPictureInPicture) { + pip.onclick = function(event) { + event.preventDefault(); + let video = getParentVideo(event.target); + videoPIP(video); + }; + } else { + pip.style.display = 'none'; + } peer.querySelector("span.fullscreen").onclick = function(event) { event.preventDefault(); @@ -1106,7 +1112,7 @@ function registerControlEvent(peerid) { } }; - let camera = peer.querySelector("span.camera"); + let camera = /** @type {HTMLElement} */(peer.querySelector("span.camera")); if(camera) { peer.querySelector("span.camera").onclick = function(event) { event.preventDefault();