浏览代码

Fixes desktop positioning and sizing.

j8
paweldomas 11 年前
父节点
当前提交
dbc0966334
共有 1 个文件被更改,包括 48 次插入16 次删除
  1. 48
    16
      app.js

+ 48
- 16
app.js 查看文件

@@ -27,6 +27,11 @@ var currentVideoHeight = null;
27 27
  * @type {function()}
28 28
  */
29 29
 var getVideoSize;
30
+/**
31
+ * Method used to get large video position.
32
+ * @type {function()}
33
+ */
34
+var getVideoPosition;
30 35
 
31 36
 /* window.onbeforeunload = closePageWarning; */
32 37
 
@@ -720,8 +725,10 @@ function updateLargeVideo(newSrc, vol) {
720 725
                 document.getElementById('largeVideo').style.webkitTransform = "none";
721 726
             }
722 727
 
723
-            // Change the way we'll be measuring large video
724
-            getVideoSize = isVideoSrcDesktop(newSrc) ? getVideoSizeFit : getVideoSizeCover;
728
+            // Change the way we'll be measuring and positioning large video
729
+            var isDesktop = isVideoSrcDesktop(newSrc);
730
+            getVideoSize = isDesktop ? getDesktopVideoSize : getCameraVideoSize;
731
+            getVideoPosition = isDesktop ? getDesktopVideoPosition : getCameraVideoPosition;
725 732
 
726 733
             if (isVisible)
727 734
                 $(this).fadeIn(300);
@@ -849,10 +856,10 @@ var positionLarge = function(videoWidth, videoHeight) {
849 856
  * @return an array with 2 elements, the horizontal indent and the vertical
850 857
  * indent
851 858
  */
852
-var getVideoPosition = function (   videoWidth,
853
-                                    videoHeight,
854
-                                    videoSpaceWidth,
855
-                                    videoSpaceHeight) {
859
+function getCameraVideoPosition(   videoWidth,
860
+                                   videoHeight,
861
+                                   videoSpaceWidth,
862
+                                   videoSpaceHeight) {
856 863
     // Parent height isn't completely calculated when we position the video in
857 864
     // full screen mode and this is why we use the screen height in this case.
858 865
     // Need to think it further at some point and implement it properly.
@@ -866,7 +873,26 @@ var getVideoPosition = function (   videoWidth,
866 873
     var verticalIndent = (videoSpaceHeight - videoHeight)/2;
867 874
 
868 875
     return [horizontalIndent, verticalIndent];
869
-};
876
+}
877
+
878
+/**
879
+ * Returns an array of the video horizontal and vertical indents.
880
+ * Centers horizontally and top aligns vertically.
881
+ *
882
+ * @return an array with 2 elements, the horizontal indent and the vertical
883
+ * indent
884
+ */
885
+function getDesktopVideoPosition(  videoWidth,
886
+                                   videoHeight,
887
+                                   videoSpaceWidth,
888
+                                   videoSpaceHeight) {
889
+
890
+    var horizontalIndent = (videoSpaceWidth - videoWidth)/2;
891
+
892
+    var verticalIndent = 0;// Top aligned
893
+
894
+    return [horizontalIndent, verticalIndent];
895
+}
870 896
 
871 897
 /**
872 898
  * Returns an array of the video dimensions, so that it covers the screen.
@@ -874,7 +900,7 @@ var getVideoPosition = function (   videoWidth,
874 900
  *
875 901
  * @return an array with 2 elements, the video width and the video height
876 902
  */
877
-function getVideoSizeCover(videoWidth,
903
+function getCameraVideoSize(videoWidth,
878 904
                            videoHeight,
879 905
                            videoSpaceWidth,
880 906
                            videoSpaceHeight) {
@@ -907,10 +933,11 @@ function getVideoSizeCover(videoWidth,
907 933
  *
908 934
  * @return an array with 2 elements, the video width and the video height
909 935
  */
910
-function getVideoSizeFit(videoWidth,
911
-                                   videoHeight,
912
-                                   videoSpaceWidth,
913
-                                   videoSpaceHeight) {
936
+function getDesktopVideoSize( videoWidth,
937
+                              videoHeight,
938
+                              videoSpaceWidth,
939
+                              videoSpaceHeight )
940
+{
914 941
     if (!videoWidth)
915 942
         videoWidth = currentVideoWidth;
916 943
     if (!videoHeight)
@@ -921,12 +948,16 @@ function getVideoSizeFit(videoWidth,
921 948
     var availableWidth = Math.max(videoWidth, videoSpaceWidth);
922 949
     var availableHeight = Math.max(videoHeight, videoSpaceHeight);
923 950
 
924
-    if (availableWidth / aspectRatio >= videoSpaceHeight) {
951
+    videoSpaceHeight -= $('#remoteVideos').outerHeight();
952
+
953
+    if (availableWidth / aspectRatio >= videoSpaceHeight)
954
+    {
925 955
         availableHeight = videoSpaceHeight;
926 956
         availableWidth = availableHeight*aspectRatio;
927 957
     }
928 958
 
929
-    if (availableHeight*aspectRatio >= videoSpaceWidth) {
959
+    if (availableHeight*aspectRatio >= videoSpaceWidth)
960
+    {
930 961
         availableWidth = videoSpaceWidth;
931 962
         availableHeight = availableWidth / aspectRatio;
932 963
     }
@@ -1005,8 +1036,9 @@ $(document).ready(function () {
1005 1036
     // Set default desktop sharing method
1006 1037
     setDesktopSharing(config.desktopSharing);
1007 1038
 
1008
-    // By default we cover the whole screen with video
1009
-    getVideoSize = getVideoSizeCover;
1039
+    // By default we use camera
1040
+    getVideoSize = getCameraVideoSize;
1041
+    getVideoPosition = getCameraVideoPosition;
1010 1042
 
1011 1043
     resizeLargeVideoContainer();
1012 1044
     $(window).resize(function () {

正在加载...
取消
保存