浏览代码

Fixes video switching issue. 'oldSmallVideo' field is no longer used as it is might be overwritten before fadeOut 'complete' callback of #largeVideo is called(and we miss UI update on it).

master
paweldomas 10 年前
父节点
当前提交
9b4ee7c0c5
共有 2 个文件被更改,包括 29 次插入24 次删除
  1. 9
    24
      modules/UI/videolayout/LargeVideo.js
  2. 20
    0
      modules/UI/videolayout/VideoLayout.js

+ 9
- 24
modules/UI/videolayout/LargeVideo.js 查看文件

@@ -13,7 +13,6 @@ var currentVideoHeight = null;
13 13
 var getVideoSize = getCameraVideoSize;
14 14
 var getVideoPosition = getCameraVideoPosition;
15 15
 var currentSmallVideo = null;
16
-var oldSmallVideo = null;
17 16
 
18 17
 
19 18
 
@@ -236,22 +235,11 @@ function changeVideo(isVisible) {
236 235
 
237 236
 
238 237
     // Only if the large video is currently visible.
239
-    // Disable previous dominant speaker video.
240
-    if (oldSmallVideo) {
241
-        oldSmallVideo.enableDominantSpeaker(false);
242
-    }
243
-
244
-    // Enable new dominant speaker in the remote videos section.
245
-    if (currentSmallVideo) {
246
-        currentSmallVideo.enableDominantSpeaker(true);
247
-    }
248
-
249 238
     if (isVisible) {
239
+        LargeVideo.VideoLayout.largeVideoUpdated(currentSmallVideo);
240
+
250 241
         $('#largeVideo').fadeIn(300);
251 242
     }
252
-
253
-    if(oldSmallVideo)
254
-        oldSmallVideo.showAvatar();
255 243
 }
256 244
 
257 245
 var LargeVideo = {
@@ -290,34 +278,31 @@ var LargeVideo = {
290 278
     /**
291 279
      * Updates the large video with the given new video source.
292 280
      */
293
-    updateLargeVideo: function(resourceJid, forceUpdate) {
281
+    updateLargeVideo: function (resourceJid, forceUpdate) {
294 282
         var newSmallVideo = this.VideoLayout.getSmallVideo(resourceJid);
295 283
         console.log('hover in ' + resourceJid + ', video: ', newSmallVideo);
296 284
 
297 285
         if (!LargeVideo.isCurrentlyOnLarge(resourceJid) || forceUpdate) {
298 286
             $('#activeSpeaker').css('visibility', 'hidden');
299 287
 
300
-            if(currentSmallVideo) {
288
+            var oldSmallVideo = null;
289
+            if (currentSmallVideo) {
301 290
                 oldSmallVideo = currentSmallVideo;
302
-            } else {
303
-                oldSmallVideo = null;
304 291
             }
305
-
306 292
             currentSmallVideo = newSmallVideo;
293
+
307 294
             var oldJid = null;
308
-            if(oldSmallVideo)
295
+            if (oldSmallVideo)
309 296
                 oldJid = oldSmallVideo.peerJid;
310
-
311 297
             if (oldJid !== resourceJid) {
312 298
                 // we want the notification to trigger even if userJid is undefined,
313 299
                 // or null.
314
-                this.eventEmitter.emit(UIEvents.SELECTED_ENDPOINT,
315
-                    resourceJid);
300
+                this.eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, resourceJid);
316 301
             }
317 302
             $('#largeVideo').fadeOut(300,
318 303
                 changeVideo.bind($('#largeVideo'), this.isLargeVideoVisible()));
319 304
         } else {
320
-            if(currentSmallVideo) {
305
+            if (currentSmallVideo) {
321 306
                 currentSmallVideo.showAvatar();
322 307
             }
323 308
         }

+ 20
- 0
modules/UI/videolayout/VideoLayout.js 查看文件

@@ -167,6 +167,26 @@ var VideoLayout = (function (my) {
167 167
         return LargeVideo.getResourceJid();
168 168
     };
169 169
 
170
+    /**
171
+     * Called when large video update is finished
172
+     * @param currentSmallVideo small video currently displayed on large video
173
+     */
174
+    my.largeVideoUpdated = function (currentSmallVideo) {
175
+        // Makes sure that dominant speaker UI
176
+        // is enabled only on current small video
177
+        localVideoThumbnail.enableDominantSpeaker(
178
+            localVideoThumbnail === currentSmallVideo);
179
+        Object.keys(remoteVideos).forEach(
180
+            function (resourceJid) {
181
+                var remoteVideo = remoteVideos[resourceJid];
182
+                if (remoteVideo) {
183
+                    remoteVideo.enableDominantSpeaker(
184
+                        remoteVideo === currentSmallVideo);
185
+                }
186
+            }
187
+        );
188
+    };
189
+
170 190
     my.handleVideoThumbClicked = function(noPinnedEndpointChangedEvent,
171 191
                                           resourceJid) {
172 192
         if(focusedVideoResourceJid) {

正在加载...
取消
保存