Kaynağa Gözat

fix(RemoteVideo): avoid black thumbnail

When the user is having connectivity issues we use the image cached in
the video element to show the preview in greyscale. It looks like this
cached image gets invalided after prolonged periods of time the video
element being hidden(and it is hidden when the video is muted). So we
never show this image if the user gets muted during connectivity
disruption in order to avoid blackness.
master
paweldomas 9 yıl önce
ebeveyn
işleme
46766ec239
1 değiştirilmiş dosya ile 49 ekleme ve 2 silme
  1. 49
    2
      modules/UI/videolayout/RemoteVideo.js

+ 49
- 2
modules/UI/videolayout/RemoteVideo.js Dosyayı Görüntüle

@@ -37,6 +37,16 @@ function RemoteVideo(user, VideoLayout, emitter) {
37 37
      * @type {boolean}
38 38
      */
39 39
     this.wasVideoPlayed = false;
40
+    /**
41
+     * The flag is set to <tt>true</tt> if remote participant's video gets muted
42
+     * during his media connection disruption. This is to prevent black video
43
+     * being render on the thumbnail, because even though once the video has
44
+     * been played the image usually remains on the video element it seems that
45
+     * after longer period of the video element being hidden this image can be
46
+     * lost.
47
+     * @type {boolean}
48
+     */
49
+    this.mutedWhileDisconnected = false;
40 50
 }
41 51
 
42 52
 RemoteVideo.prototype = Object.create(SmallVideo.prototype);
@@ -179,6 +189,33 @@ RemoteVideo.prototype.updateRemoteVideoMenu = function (isMuted, force) {
179 189
     }
180 190
 };
181 191
 
192
+/**
193
+ * @inheritDoc
194
+ */
195
+RemoteVideo.prototype.setMutedView = function(isMuted) {
196
+    SmallVideo.prototype.setMutedView.call(this, isMuted);
197
+    // Update 'mutedWhileDisconnected' flag
198
+    this._figureOutMutedWhileDisconnected(this.isConnectionActive() === false);
199
+}
200
+
201
+/**
202
+ * Figures out the value of {@link #mutedWhileDisconnected} flag by taking into
203
+ * account remote participant's network connectivity and video muted status.
204
+ *
205
+ * @param {boolean} isDisconnected <tt>true</tt> if the remote participant is
206
+ * currently having connectivity issues or <tt>false</tt> otherwise.
207
+ *
208
+ * @private
209
+ */
210
+RemoteVideo.prototype._figureOutMutedWhileDisconnected
211
+= function(isDisconnected) {
212
+    if (isDisconnected && this.isVideoMuted) {
213
+        this.mutedWhileDisconnected = true;
214
+    } else if (!isDisconnected && !this.isVideoMuted) {
215
+        this.mutedWhileDisconnected = false;
216
+    }
217
+}
218
+
182 219
 /**
183 220
  * Adds the remote video menu element for the given <tt>id</tt> in the
184 221
  * given <tt>parentElement</tt>.
@@ -237,6 +274,9 @@ RemoteVideo.prototype.removeRemoteStreamElement = function (stream) {
237 274
     // update the stage
238 275
     if (isVideo && this.isCurrentlyOnLargeVideo())
239 276
         this.VideoLayout.updateLargeVideo(this.id);
277
+    else
278
+        // Missing video stream will affect display mode
279
+        this.updateView();
240 280
 };
241 281
 
242 282
 /**
@@ -259,16 +299,20 @@ RemoteVideo.prototype.isConnectionActive = function() {
259 299
  */
260 300
 RemoteVideo.prototype.isVideoPlayable = function () {
261 301
     return SmallVideo.prototype.isVideoPlayable.call(this)
262
-        && this.hasVideoStarted();
302
+        && this.hasVideoStarted() && !this.mutedWhileDisconnected;
263 303
 };
264 304
 
265 305
 /**
266 306
  * @inheritDoc
267 307
  */
268 308
 RemoteVideo.prototype.updateView = function () {
269
-    SmallVideo.prototype.updateView.call(this);
309
+
270 310
     this.updateConnectionStatusIndicator(
271 311
         null /* will obtain the status from 'conference' */);
312
+
313
+    // This must be called after 'updateConnectionStatusIndicator' because it
314
+    // affects the display mode by modifying 'mutedWhileDisconnected' flag
315
+    SmallVideo.prototype.updateView.call(this);
272 316
 };
273 317
 
274 318
 /**
@@ -290,6 +334,9 @@ RemoteVideo.prototype.updateConnectionStatusIndicator = function (isActive) {
290 334
 
291 335
     console.debug(this.id + " thumbnail is connection active ? " + isActive);
292 336
 
337
+    // Update 'mutedWhileDisconnected' flag
338
+    this._figureOutMutedWhileDisconnected(!isActive);
339
+
293 340
     if(this.connectionIndicator)
294 341
         this.connectionIndicator.updateConnectionStatusIndicator(isActive);
295 342
 

Loading…
İptal
Kaydet