Browse Source

Fixes desktop streaming layout.

master
yanas 9 years ago
parent
commit
26e2fd6ef0

+ 5
- 1
modules/UI/UI.js View File

@@ -107,7 +107,7 @@ function setupChat() {
107 107
 function setupToolbars() {
108 108
     Toolbar.init(UI);
109 109
     Toolbar.setupButtonsFromConfig();
110
-    BottomToolbar.init();
110
+    BottomToolbar.init(eventEmitter);
111 111
 }
112 112
 
113 113
 function streamHandler(stream, isMuted) {
@@ -343,6 +343,10 @@ function registerListeners() {
343 343
         AudioLevels.init();
344 344
     });
345 345
 
346
+    UI.addListener(UIEvents.FILM_STRIP_TOGGLED, function (isToggled) {
347
+        VideoLayout.onFilmStripToggled(isToggled);
348
+    });
349
+
346 350
     if (!interfaceConfig.filmStripOnly) {
347 351
         APP.xmpp.addListener(XMPPEvents.MESSAGE_RECEIVED, updateChatConversation);
348 352
         APP.xmpp.addListener(XMPPEvents.CHAT_ERROR_RECEIVED, chatAddError);

+ 8
- 1
modules/UI/toolbars/BottomToolbar.js View File

@@ -2,6 +2,9 @@
2 2
 var PanelToggler = require("../side_pannels/SidePanelToggler");
3 3
 var UIUtil = require("../util/UIUtil");
4 4
 var AnalyticsAdapter = require("../../statistics/AnalyticsAdapter");
5
+var UIEvents = require("../../../service/UI/UIEvents");
6
+
7
+var eventEmitter = null;
5 8
 
6 9
 var buttonHandlers = {
7 10
     "bottom_toolbar_contact_list": function () {
@@ -27,7 +30,8 @@ var defaultBottomToolbarButtons = {
27 30
 
28 31
 
29 32
 var BottomToolbar = (function (my) {
30
-    my.init = function () {
33
+    my.init = function (emitter) {
34
+        eventEmitter = emitter;
31 35
         UIUtil.hideDisabledButtons(defaultBottomToolbarButtons);
32 36
 
33 37
         for(var k in buttonHandlers)
@@ -45,6 +49,9 @@ var BottomToolbar = (function (my) {
45 49
     my.toggleFilmStrip = function() {
46 50
         var filmstrip = $("#remoteVideos");
47 51
         filmstrip.toggleClass("hidden");
52
+
53
+        eventEmitter.emit(  UIEvents.FILM_STRIP_TOGGLED,
54
+                            filmstrip.hasClass("hidden"));
48 55
     };
49 56
 
50 57
     $(document).bind("remotevideo.resized", function (event, width, height) {

+ 48
- 22
modules/UI/videolayout/LargeVideo.js View File

@@ -115,7 +115,10 @@ function getDesktopVideoSize(videoWidth,
115 115
     var availableWidth = Math.max(videoWidth, videoSpaceWidth);
116 116
     var availableHeight = Math.max(videoHeight, videoSpaceHeight);
117 117
 
118
-    videoSpaceHeight -= $('#remoteVideos').outerHeight();
118
+    var filmstrip = $("#remoteVideos");
119
+
120
+    if (!filmstrip.hasClass("hidden"))
121
+        videoSpaceHeight -= filmstrip.outerHeight();
119 122
 
120 123
     if (availableWidth / aspectRatio >= videoSpaceHeight)
121 124
     {
@@ -268,13 +271,7 @@ function changeVideo(isVisible) {
268 271
 
269 272
     largeVideoElement.style.transform = flipX ? "scaleX(-1)" : "none";
270 273
 
271
-    var isDesktop = currentSmallVideo.getVideoType() === 'screen';
272
-    // Change the way we'll be measuring and positioning large video
273
-
274
-    getVideoSize = isDesktop ? getDesktopVideoSize : getCameraVideoSize;
275
-    getVideoPosition = isDesktop ? getDesktopVideoPosition :
276
-        getCameraVideoPosition;
277
-
274
+    LargeVideo.updateVideoSizeAndPosition(currentSmallVideo.getVideoType());
278 275
 
279 276
     // Only if the large video is currently visible.
280 277
     if (isVisible) {
@@ -451,10 +448,8 @@ var LargeVideo = {
451 448
             return;
452 449
         if (LargeVideo.isCurrentlyOnLarge(resourceJid))
453 450
         {
454
-            var isDesktop = newVideoType === 'screen';
455
-            getVideoSize = isDesktop ? getDesktopVideoSize : getCameraVideoSize;
456
-            getVideoPosition = isDesktop ? getDesktopVideoPosition
457
-                : getCameraVideoPosition;
451
+            LargeVideo.updateVideoSizeAndPosition(newVideoType);
452
+
458 453
             this.position(null, null, null, null, true);
459 454
         }
460 455
     },
@@ -496,17 +491,23 @@ var LargeVideo = {
496 491
     },
497 492
     /**
498 493
      * Resizes the large html elements.
499
-     * @param animate boolean property that indicates whether the resize should be animated or not.
500
-     * @param isChatVisible boolean property that indicates whether the chat area is displayed or not.
501
-     * If that parameter is null the method will check the chat pannel visibility.
502
-     * @param completeFunction a function to be called when the video space is resized
503
-     * @returns {*[]} array with the current width and height values of the largeVideo html element.
494
+     *
495
+     * @param animate boolean property that indicates whether the resize should
496
+     * be animated or not.
497
+     * @param isSideBarVisible boolean property that indicates whether the chat
498
+     * area is displayed or not.
499
+     * If that parameter is null the method will check the chat panel
500
+     * visibility.
501
+     * @param completeFunction a function to be called when the video space is
502
+     * resized
503
+     * @returns {*[]} array with the current width and height values of the
504
+     * largeVideo html element.
504 505
      */
505
-    resize: function (animate, isVisible, completeFunction) {
506
+    resize: function (animate, isSideBarVisible, completeFunction) {
506 507
         if(!isEnabled)
507 508
             return;
508 509
         var availableHeight = window.innerHeight;
509
-        var availableWidth = UIUtil.getAvailableVideoWidth(isVisible);
510
+        var availableWidth = UIUtil.getAvailableVideoWidth(isSideBarVisible);
510 511
 
511 512
         if (availableWidth < 0 || availableHeight < 0) return;
512 513
 
@@ -514,7 +515,8 @@ var LargeVideo = {
514 515
         var top = availableHeight / 2 - avatarSize / 4 * 3;
515 516
         $('#activeSpeaker').css('top', top);
516 517
 
517
-        this.VideoLayout.resizeVideoSpace(animate, isVisible, completeFunction);
518
+        this.VideoLayout
519
+            .resizeVideoSpace(animate, isSideBarVisible, completeFunction);
518 520
         if(animate) {
519 521
             $('#largeVideoContainer').animate({
520 522
                     width: availableWidth,
@@ -530,12 +532,36 @@ var LargeVideo = {
530 532
         }
531 533
         return [availableWidth, availableHeight];
532 534
     },
533
-    resizeVideoAreaAnimated: function (isVisible, completeFunction) {
535
+    /**
536
+     * Resizes the large video.
537
+     *
538
+     * @param isSideBarVisible indicating if the side bar is visible
539
+     * @param completeFunction the callback function to be executed after the
540
+     * resize
541
+     */
542
+    resizeVideoAreaAnimated: function (isSideBarVisible, completeFunction) {
534 543
         if(!isEnabled)
535 544
             return;
536
-        var size = this.resize(true, isVisible, completeFunction);
545
+        var size = this.resize(true, isSideBarVisible, completeFunction);
537 546
         this.position(null, null, size[0], size[1], true);
538 547
     },
548
+    /**
549
+     * Updates the video size and position.
550
+     *
551
+     * @param videoType the video type indicating if the stream is of type
552
+     * desktop or web cam
553
+     */
554
+    updateVideoSizeAndPosition: function (videoType) {
555
+        if (!videoType)
556
+            videoType = currentSmallVideo.getVideoType();
557
+
558
+        var isDesktop = videoType === 'screen';
559
+
560
+        // Change the way we'll be measuring and positioning large video
561
+        getVideoSize = isDesktop ? getDesktopVideoSize : getCameraVideoSize;
562
+        getVideoPosition = isDesktop ? getDesktopVideoPosition :
563
+            getCameraVideoPosition;
564
+    },
539 565
     getResourceJid: function () {
540 566
         return currentSmallVideo ? currentSmallVideo.getResourceJid() : null;
541 567
     },

+ 41
- 16
modules/UI/videolayout/VideoLayout.js View File

@@ -214,7 +214,8 @@ var VideoLayout = (function (my) {
214 214
     my.handleVideoThumbClicked = function(noPinnedEndpointChangedEvent,
215 215
                                           resourceJid) {
216 216
         if(focusedVideoResourceJid) {
217
-            var oldSmallVideo = VideoLayout.getSmallVideo(focusedVideoResourceJid);
217
+            var oldSmallVideo
218
+                    = VideoLayout.getSmallVideo(focusedVideoResourceJid);
218 219
             if (oldSmallVideo && !interfaceConfig.filmStripOnly)
219 220
                 oldSmallVideo.focus(false);
220 221
         }
@@ -400,7 +401,8 @@ var VideoLayout = (function (my) {
400 401
 
401 402
         if(animate) {
402 403
             $('#remoteVideos').animate({
403
-                    height: height + 2 // adds 2 px because of small video 1px border
404
+                    // adds 2 px because of small video 1px border
405
+                    height: height + 2
404 406
                 },
405 407
                 {
406 408
                     queue: false,
@@ -425,7 +427,8 @@ var VideoLayout = (function (my) {
425 427
         } else {
426 428
             // size videos so that while keeping AR and max height, we have a
427 429
             // nice fit
428
-            $('#remoteVideos').height(height + 2);// adds 2 px because of small video 1px border
430
+            // adds 2 px because of small video 1px border
431
+            $('#remoteVideos').height(height + 2);
429 432
             $('#remoteVideos>span').width(width);
430 433
             $('#remoteVideos>span').height(height);
431 434
 
@@ -439,10 +442,10 @@ var VideoLayout = (function (my) {
439 442
      * @param videoSpaceWidth the width of the video space
440 443
      */
441 444
     my.calculateThumbnailSize = function (videoSpaceWidth) {
442
-        // Calculate the available height, which is the inner window height minus
443
-       // 39px for the header minus 2px for the delimiter lines on the top and
444
-       // bottom of the large video, minus the 36px space inside the remoteVideos
445
-       // container used for highlighting shadow.
445
+        // Calculate the available height, which is the inner window height
446
+        // minus 39px for the header minus 2px for the delimiter lines on the
447
+        // top and bottom of the large video, minus the 36px space inside the
448
+        // remoteVideos container used for highlighting shadow.
446 449
        var availableHeight = 100;
447 450
 
448 451
         var numvids = $('#remoteVideos>span:visible').length;
@@ -458,7 +461,11 @@ var VideoLayout = (function (my) {
458 461
        var availableWidth = availableWinWidth / numvids;
459 462
        var aspectRatio = 16.0 / 9.0;
460 463
        var maxHeight = Math.min(160, availableHeight);
461
-       availableHeight = Math.min(maxHeight, availableWidth / aspectRatio, window.innerHeight - 18);
464
+       availableHeight
465
+           = Math.min(  maxHeight,
466
+                        availableWidth / aspectRatio,
467
+                        window.innerHeight - 18);
468
+
462 469
        if (availableHeight < availableWidth / aspectRatio) {
463 470
            availableWidth = Math.floor(availableHeight * aspectRatio);
464 471
        }
@@ -882,6 +889,17 @@ var VideoLayout = (function (my) {
882 889
 
883 890
     };
884 891
 
892
+    /**
893
+     * Updates the video size and position when the film strip is toggled.
894
+     *
895
+     * @param isToggled indicates if the film strip is toggled or not. True
896
+     * would mean that the film strip is hidden, false would mean it's shown
897
+     */
898
+    my.onFilmStripToggled = function(isToggled) {
899
+        LargeVideo.updateVideoSizeAndPosition();
900
+        LargeVideo.position(null, null, null, null, true);
901
+    };
902
+
885 903
     my.showMore = function (jid) {
886 904
         if (jid === 'local') {
887 905
             localVideoThumbnail.connectionIndicator.showMore();
@@ -914,21 +932,27 @@ var VideoLayout = (function (my) {
914 932
     };
915 933
 
916 934
     /**
917
-     * Resizes the video area
935
+     * Resizes the video area.
936
+     *
937
+     * @param isSideBarVisible indicates if the side bar is currently visible
918 938
      * @param callback a function to be called when the video space is
919 939
      * resized.
920 940
      */
921
-    my.resizeVideoArea = function(isVisible, callback) {
922
-        LargeVideo.resizeVideoAreaAnimated(isVisible, callback);
941
+    my.resizeVideoArea = function(isSideBarVisible, callback) {
942
+        LargeVideo.resizeVideoAreaAnimated(isSideBarVisible, callback);
923 943
         VideoLayout.resizeThumbnails(true);
924 944
     };
925 945
 
926 946
     /**
927 947
      * Resizes the #videospace html element
928
-     * @param animate boolean property that indicates whether the resize should be animated or not.
929
-     * @param isChatVisible boolean property that indicates whether the chat area is displayed or not.
930
-     * If that parameter is null the method will check the chat pannel visibility.
931
-     * @param completeFunction a function to be called when the video space is resized
948
+     * @param animate boolean property that indicates whether the resize should
949
+     * be animated or not.
950
+     * @param isChatVisible boolean property that indicates whether the chat
951
+     * area is displayed or not.
952
+     * If that parameter is null the method will check the chat panel
953
+     * visibility.
954
+     * @param completeFunction a function to be called when the video space
955
+     * is resized.
932 956
      */
933 957
     my.resizeVideoSpace = function (animate, isChatVisible, completeFunction) {
934 958
         var availableHeight = window.innerHeight;
@@ -998,7 +1022,8 @@ var VideoLayout = (function (my) {
998 1022
         LargeVideo.enableVideoProblemFilter(true);
999 1023
         var reconnectingKey = "connection.RECONNECTING";
1000 1024
         $('#videoConnectionMessage').attr("data-i18n", reconnectingKey);
1001
-        $('#videoConnectionMessage').text(APP.translation.translateString(reconnectingKey));
1025
+        $('#videoConnectionMessage')
1026
+            .text(APP.translation.translateString(reconnectingKey));
1002 1027
         $('#videoConnectionMessage').css({display: "block"});
1003 1028
     };
1004 1029
 

+ 6
- 1
service/UI/UIEvents.js View File

@@ -2,6 +2,11 @@ var UIEvents = {
2 2
     NICKNAME_CHANGED: "UI.nickname_changed",
3 3
     SELECTED_ENDPOINT: "UI.selected_endpoint",
4 4
     PINNED_ENDPOINT: "UI.pinned_endpoint",
5
-    LARGEVIDEO_INIT: "UI.largevideo_init"
5
+    LARGEVIDEO_INIT: "UI.largevideo_init",
6
+    /**
7
+     * Notifies interested parties when the film strip (remote video's panel)
8
+     * is hidden (toggled) or shown (un-toggled).
9
+     */
10
+    FILM_STRIP_TOGGLED: "UI.filmstrip_toggled"
6 11
 };
7 12
 module.exports = UIEvents;

Loading…
Cancel
Save