浏览代码

Fixes exception in follow-me when we receive an update for a video thumbnail that's not there yet.

master
yanas 10 年前
父节点
当前提交
ea9b909775
共有 2 个文件被更改,包括 69 次插入11 次删除
  1. 55
    7
      modules/FollowMe.js
  2. 14
    4
      modules/UI/videolayout/SmallVideo.js

+ 55
- 7
modules/FollowMe.js 查看文件

@@ -25,6 +25,15 @@ import FilmStrip from './UI/videolayout/FilmStrip';
25 25
  */
26 26
 const _COMMAND = "follow-me";
27 27
 
28
+/**
29
+ * The timeout after which a follow-me command that has been received will be
30
+ * ignored if not consumed.
31
+ *
32
+ * @type {number} in seconds
33
+ * @private
34
+ */
35
+const _FOLLOW_ME_RECEIVED_TIMEOUT = 30;
36
+
28 37
 /**
29 38
  * Represents the set of {FollowMe}-related states (properties and their
30 39
  * respective values) which are to be followed by a participant. {FollowMe}
@@ -112,6 +121,7 @@ class FollowMe {
112 121
     constructor (conference, UI) {
113 122
         this._conference = conference;
114 123
         this._UI = UI;
124
+        this.nextOnStageTimer = 0;
115 125
 
116 126
         // The states of the local participant which are to be followed (by the
117 127
         // remote participants when the local participant is in her right to
@@ -265,6 +275,7 @@ class FollowMe {
265 275
         // issued by a defined commander.
266 276
         if (typeof id === 'undefined')
267 277
             return;
278
+
268 279
         // The Command(s) API will send us our own commands and we don't want
269 280
         // to act upon them.
270 281
         if (this._conference.isLocalId(id))
@@ -297,22 +308,24 @@ class FollowMe {
297 308
             // writing whether calling UI.toggleFilmStrip() is acceptable (from
298 309
             // a design standpoint) either.
299 310
             if (filmStripVisible !== FilmStrip.isFilmStripVisible())
300
-                this._UI.eventEmitter.emit(
301
-                    UIEvents.TOGGLE_FILM_STRIP,
302
-                    filmStripVisible);
311
+                this._UI.eventEmitter.emit(UIEvents.TOGGLE_FILM_STRIP);
303 312
         }
304 313
     }
305 314
 
306 315
     _onNextOnStage(id) {
307
-
308 316
         var clickId = null;
309
-        if(typeof id !== 'undefined' && !VideoLayout.isPinned(id))
317
+        var pin;
318
+        if(typeof id !== 'undefined' && !VideoLayout.isPinned(id)) {
310 319
             clickId = id;
311
-        else if (typeof id == 'undefined' && VideoLayout.getPinnedId())
320
+            pin = true;
321
+        }
322
+        else if (typeof id == 'undefined' && VideoLayout.getPinnedId()) {
312 323
             clickId = VideoLayout.getPinnedId();
324
+            pin = false;
325
+        }
313 326
 
314 327
         if (clickId)
315
-            VideoLayout.handleVideoThumbClicked(clickId);
328
+            this._pinVideoThumbnailById(clickId, pin);
316 329
     }
317 330
 
318 331
     _onSharedDocumentVisible(sharedDocumentVisible) {
@@ -328,6 +341,41 @@ class FollowMe {
328 341
                 this._UI.getSharedDocumentManager().toggleEtherpad();
329 342
         }
330 343
     }
344
+
345
+    /**
346
+     * Pins / unpins the video thumbnail given by clickId.
347
+     *
348
+     * @param clickId the identifier of the video thumbnail to pin or unpin
349
+     * @param pin {true} to pin, {false} to unpin
350
+     * @private
351
+     */
352
+    _pinVideoThumbnailById(clickId, pin) {
353
+        var self = this;
354
+        var smallVideo = VideoLayout.getSmallVideo(clickId);
355
+
356
+        // If the SmallVideo for the given clickId exists we proceed with the
357
+        // pin/unpin.
358
+        if (smallVideo) {
359
+            this.nextOnStageTimer = 0;
360
+            clearTimeout(this.nextOnStageTimout);
361
+            if (pin && !VideoLayout.isPinned(clickId)
362
+                || !pin && VideoLayout.isPinned(clickId))
363
+                VideoLayout.handleVideoThumbClicked(clickId);
364
+        }
365
+        // If there's no SmallVideo object for the given id, lets wait and see
366
+        // if it's going to be created in the next 30sec.
367
+        else {
368
+            this.nextOnStageTimout = setTimeout(function () {
369
+                if (self.nextOnStageTimer > _FOLLOW_ME_RECEIVED_TIMEOUT) {
370
+                    self.nextOnStageTimer = 0;
371
+                    return;
372
+                }
373
+
374
+                this.nextOnStageTimer++;
375
+                self._pinVideoThumbnailById(clickId, pin);
376
+            }, 1000);
377
+        }
378
+    }
331 379
 }
332 380
 
333 381
 export default FollowMe;

+ 14
- 4
modules/UI/videolayout/SmallVideo.js 查看文件

@@ -315,11 +315,21 @@ SmallVideo.prototype.selectVideoElement = function () {
315 315
     return $(RTCUIHelper.findVideoElement($('#' + this.videoSpanId)[0]));
316 316
 };
317 317
 
318
+/**
319
+ * Enables / disables the css responsible for focusing/pinning a video
320
+ * thumbnail.
321
+ *
322
+ * @param isFocused indicates if the thumbnail should be focused/pinned or not
323
+ */
318 324
 SmallVideo.prototype.focus = function(isFocused) {
319
-    if(!isFocused) {
320
-        this.container.classList.remove("videoContainerFocused");
321
-    } else {
322
-        this.container.classList.add("videoContainerFocused");
325
+    var focusedCssClass = "videoContainerFocused";
326
+    var isFocusClassEnabled = $(this.container).hasClass(focusedCssClass);
327
+
328
+    if (!isFocused && isFocusClassEnabled) {
329
+        $(this.container).removeClass(focusedCssClass);
330
+    }
331
+    else if (isFocused && !isFocusClassEnabled) {
332
+        $(this.container).addClass(focusedCssClass);
323 333
     }
324 334
 };
325 335
 

正在加载...
取消
保存