Browse Source

Fixes desktop streaming layout.

master
yanas 10 years ago
parent
commit
26e2fd6ef0

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

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

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

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

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

115
     var availableWidth = Math.max(videoWidth, videoSpaceWidth);
115
     var availableWidth = Math.max(videoWidth, videoSpaceWidth);
116
     var availableHeight = Math.max(videoHeight, videoSpaceHeight);
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
     if (availableWidth / aspectRatio >= videoSpaceHeight)
123
     if (availableWidth / aspectRatio >= videoSpaceHeight)
121
     {
124
     {
268
 
271
 
269
     largeVideoElement.style.transform = flipX ? "scaleX(-1)" : "none";
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
     // Only if the large video is currently visible.
276
     // Only if the large video is currently visible.
280
     if (isVisible) {
277
     if (isVisible) {
451
             return;
448
             return;
452
         if (LargeVideo.isCurrentlyOnLarge(resourceJid))
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
             this.position(null, null, null, null, true);
453
             this.position(null, null, null, null, true);
459
         }
454
         }
460
     },
455
     },
496
     },
491
     },
497
     /**
492
     /**
498
      * Resizes the large html elements.
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
         if(!isEnabled)
507
         if(!isEnabled)
507
             return;
508
             return;
508
         var availableHeight = window.innerHeight;
509
         var availableHeight = window.innerHeight;
509
-        var availableWidth = UIUtil.getAvailableVideoWidth(isVisible);
510
+        var availableWidth = UIUtil.getAvailableVideoWidth(isSideBarVisible);
510
 
511
 
511
         if (availableWidth < 0 || availableHeight < 0) return;
512
         if (availableWidth < 0 || availableHeight < 0) return;
512
 
513
 
514
         var top = availableHeight / 2 - avatarSize / 4 * 3;
515
         var top = availableHeight / 2 - avatarSize / 4 * 3;
515
         $('#activeSpeaker').css('top', top);
516
         $('#activeSpeaker').css('top', top);
516
 
517
 
517
-        this.VideoLayout.resizeVideoSpace(animate, isVisible, completeFunction);
518
+        this.VideoLayout
519
+            .resizeVideoSpace(animate, isSideBarVisible, completeFunction);
518
         if(animate) {
520
         if(animate) {
519
             $('#largeVideoContainer').animate({
521
             $('#largeVideoContainer').animate({
520
                     width: availableWidth,
522
                     width: availableWidth,
530
         }
532
         }
531
         return [availableWidth, availableHeight];
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
         if(!isEnabled)
543
         if(!isEnabled)
535
             return;
544
             return;
536
-        var size = this.resize(true, isVisible, completeFunction);
545
+        var size = this.resize(true, isSideBarVisible, completeFunction);
537
         this.position(null, null, size[0], size[1], true);
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
     getResourceJid: function () {
565
     getResourceJid: function () {
540
         return currentSmallVideo ? currentSmallVideo.getResourceJid() : null;
566
         return currentSmallVideo ? currentSmallVideo.getResourceJid() : null;
541
     },
567
     },

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

214
     my.handleVideoThumbClicked = function(noPinnedEndpointChangedEvent,
214
     my.handleVideoThumbClicked = function(noPinnedEndpointChangedEvent,
215
                                           resourceJid) {
215
                                           resourceJid) {
216
         if(focusedVideoResourceJid) {
216
         if(focusedVideoResourceJid) {
217
-            var oldSmallVideo = VideoLayout.getSmallVideo(focusedVideoResourceJid);
217
+            var oldSmallVideo
218
+                    = VideoLayout.getSmallVideo(focusedVideoResourceJid);
218
             if (oldSmallVideo && !interfaceConfig.filmStripOnly)
219
             if (oldSmallVideo && !interfaceConfig.filmStripOnly)
219
                 oldSmallVideo.focus(false);
220
                 oldSmallVideo.focus(false);
220
         }
221
         }
400
 
401
 
401
         if(animate) {
402
         if(animate) {
402
             $('#remoteVideos').animate({
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
                     queue: false,
408
                     queue: false,
425
         } else {
427
         } else {
426
             // size videos so that while keeping AR and max height, we have a
428
             // size videos so that while keeping AR and max height, we have a
427
             // nice fit
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
             $('#remoteVideos>span').width(width);
432
             $('#remoteVideos>span').width(width);
430
             $('#remoteVideos>span').height(height);
433
             $('#remoteVideos>span').height(height);
431
 
434
 
439
      * @param videoSpaceWidth the width of the video space
442
      * @param videoSpaceWidth the width of the video space
440
      */
443
      */
441
     my.calculateThumbnailSize = function (videoSpaceWidth) {
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
        var availableHeight = 100;
449
        var availableHeight = 100;
447
 
450
 
448
         var numvids = $('#remoteVideos>span:visible').length;
451
         var numvids = $('#remoteVideos>span:visible').length;
458
        var availableWidth = availableWinWidth / numvids;
461
        var availableWidth = availableWinWidth / numvids;
459
        var aspectRatio = 16.0 / 9.0;
462
        var aspectRatio = 16.0 / 9.0;
460
        var maxHeight = Math.min(160, availableHeight);
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
        if (availableHeight < availableWidth / aspectRatio) {
469
        if (availableHeight < availableWidth / aspectRatio) {
463
            availableWidth = Math.floor(availableHeight * aspectRatio);
470
            availableWidth = Math.floor(availableHeight * aspectRatio);
464
        }
471
        }
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
     my.showMore = function (jid) {
903
     my.showMore = function (jid) {
886
         if (jid === 'local') {
904
         if (jid === 'local') {
887
             localVideoThumbnail.connectionIndicator.showMore();
905
             localVideoThumbnail.connectionIndicator.showMore();
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
      * @param callback a function to be called when the video space is
938
      * @param callback a function to be called when the video space is
919
      * resized.
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
         VideoLayout.resizeThumbnails(true);
943
         VideoLayout.resizeThumbnails(true);
924
     };
944
     };
925
 
945
 
926
     /**
946
     /**
927
      * Resizes the #videospace html element
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
     my.resizeVideoSpace = function (animate, isChatVisible, completeFunction) {
957
     my.resizeVideoSpace = function (animate, isChatVisible, completeFunction) {
934
         var availableHeight = window.innerHeight;
958
         var availableHeight = window.innerHeight;
998
         LargeVideo.enableVideoProblemFilter(true);
1022
         LargeVideo.enableVideoProblemFilter(true);
999
         var reconnectingKey = "connection.RECONNECTING";
1023
         var reconnectingKey = "connection.RECONNECTING";
1000
         $('#videoConnectionMessage').attr("data-i18n", reconnectingKey);
1024
         $('#videoConnectionMessage').attr("data-i18n", reconnectingKey);
1001
-        $('#videoConnectionMessage').text(APP.translation.translateString(reconnectingKey));
1025
+        $('#videoConnectionMessage')
1026
+            .text(APP.translation.translateString(reconnectingKey));
1002
         $('#videoConnectionMessage').css({display: "block"});
1027
         $('#videoConnectionMessage').css({display: "block"});
1003
     };
1028
     };
1004
 
1029
 

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

2
     NICKNAME_CHANGED: "UI.nickname_changed",
2
     NICKNAME_CHANGED: "UI.nickname_changed",
3
     SELECTED_ENDPOINT: "UI.selected_endpoint",
3
     SELECTED_ENDPOINT: "UI.selected_endpoint",
4
     PINNED_ENDPOINT: "UI.pinned_endpoint",
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
 module.exports = UIEvents;
12
 module.exports = UIEvents;

Loading…
Cancel
Save