Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
Encapsulates direct access to .currentTime field into 'hasVideoStarted' method of RemoteVideo. Removes duplicated logic for hiding video element when the user is muted.
paweldomas103b5d71d028
diff --git a/modules/UI/videolayout/RemoteVideo.js b/modules/UI/videolayout/RemoteVideo.jsindex e1908869a9..e1e68d8d50 100644--- a/modules/UI/videolayout/RemoteVideo.js+++ b/modules/UI/videolayout/RemoteVideo.js@@ -205,6 +205,18 @@ RemoteVideo.prototype.waitForPlayback = function (streamElement, stream) {streamElement.onplaying = onPlayingHandler;};+/**+ * Checks whether or not video stream exists and has started for this+ * RemoteVideo instance. This is checked by trying to select video element in+ * this container and checking if 'currentTime' field's value is greater than 0.+ *+ * @returns {*|boolean} true if this RemoteVideo has active video stream running+ */+RemoteVideo.prototype.hasVideoStarted = function () {+ var videoSelector = this.selectVideoElement();+ return videoSelector.length && videoSelector[0].currentTime > 0;+};+RemoteVideo.prototype.addRemoteStreamElement = function (stream) {if (!this.container) {return;diff --git a/modules/UI/videolayout/VideoLayout.js b/modules/UI/videolayout/VideoLayout.jsindex 7ee3ac5f02..8a375fe95e 100644--- a/modules/UI/videolayout/VideoLayout.js+++ b/modules/UI/videolayout/VideoLayout.js@@ -46,11 +46,10 @@ function onContactClicked (id) {}let remoteVideo = remoteVideos[id];- if (remoteVideo && remoteVideo.selectVideoElement().length) {+ if (remoteVideo && remoteVideo.hasVideo()) {// It is not always the case that a videoThumb exists (if there is// no actual video).- if (remoteVideo.videoStream) {-+ if (remoteVideo.hasVideoStarted()) {// We have a video src, great! Let's update the large video// now.VideoLayout.handleVideoThumbClicked(false, id);@@ -517,12 +516,6 @@ var VideoLayout = {} else {var remoteVideo = remoteVideos[id];remoteVideo.setMutedView(value);-- var el = remoteVideo.selectVideoElement();- if (!value)- el.show();- else- el.hide();}if(this.isCurrentlyOnLarge(id))@@ -575,17 +568,12 @@ var VideoLayout = {}currentDominantSpeaker = id;- // Obtain container for new dominant speaker.- let videoSel = remoteVideo.selectVideoElement();-// Local video will not have container found, but that's ok// since we don't want to switch to local video.- if (!focusedVideoResourceJid && videoSel.length) {- // Update the large video if the video source is already available,- // otherwise wait for the "videoactive.jingle" event.- if (videoSel[0].currentTime > 0) {- this.updateLargeVideo(id);- }+ // Update the large video if the video source is already available,+ // otherwise wait for the "videoactive.jingle" event.+ if (!focusedVideoResourceJid && remoteVideo.hasVideoStarted()) {+ this.updateLargeVideo(id);}},