Procházet zdrojové kódy

move video elements into container elements

master
Philipp Hancke před 11 roky
rodič
revize
ab1ac06e83
3 změnil soubory, kde provedl 45 přidání a 23 odebrání
  1. 19
    9
      app.js
  2. 20
    12
      css/main.css
  3. 6
    2
      index.html

+ 19
- 9
app.js Zobrazit soubor

@@ -96,12 +96,22 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
96 96
     }
97 97
     var sess = connection.jingle.sessions[sid];
98 98
     var vid = document.createElement('video');
99
+    console.log(sess);
100
+    var span = document.createElement('span');
101
+    // FIXME: how to name this span? sess.peerjid is not right for jingle clients
102
+    //console.log('peer: ', Strophe.getResourceFromJid(sess.peerjid));
103
+    //span.id = 'remoteVideocontainer_' + Strophe.getResourceFromJid(sess.peerjid);
104
+    span.className = 'videocontainer';
99 105
     var id = 'remoteVideo_' + sid + '_' + data.stream.id;
100 106
     vid.id = id;
101 107
     vid.autoplay = true;
102 108
     vid.oncontextmenu = function () { return false; };
103 109
     var remotes = document.getElementById('remoteVideos');
104
-    remotes.appendChild(vid);
110
+    span.appendChild(vid);
111
+    if (id.indexOf('mixedmslabel') != -1) {
112
+        $(span).hide();
113
+    }
114
+    remotes.appendChild(span);
105 115
     var sel = $('#' + id);
106 116
     sel.hide();
107 117
     RTC.attachMediaStream(sel, data.stream);
@@ -109,12 +119,12 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
109 119
     data.stream.onended = function () {
110 120
         console.log('stream ended', this.id);
111 121
         var src = $('#' + id).attr('src');
112
-        $('#' + id).remove();
122
+        $('#' + id).parent().remove();
113 123
         if (src === $('#largeVideo').attr('src')) {
114 124
             // this is currently displayed as large
115 125
             // pick the last visible video in the row
116 126
             // if nobody else is left, this picks the local video
117
-            var pick = $('#remoteVideos :visible:last').get(0);
127
+            var pick = $('#remoteVideos>span:visible:last>video').get(0);
118 128
             // mute if localvideo
119 129
             document.getElementById('largeVideo').volume = pick.volume;
120 130
             document.getElementById('largeVideo').src = pick.src;
@@ -269,8 +279,8 @@ function resizeLarge() {
269 279
         availableWidth = Math.floor(availableHeight * aspectRatio);
270 280
     }
271 281
     if (availableWidth < 0 || availableHeight < 0) return;
272
-    $('#largeVideo').width(availableWidth);
273
-    $('#largeVideo').height(availableWidth / aspectRatio);
282
+    $('#largeVideo').parent().width(availableWidth);
283
+    $('#largeVideo').parent().height(availableWidth / aspectRatio);
274 284
     resizeThumbnails();
275 285
 }
276 286
 
@@ -279,7 +289,7 @@ function resizeThumbnails() {
279 289
     // minus 4px for the delimiter lines on the top and bottom of the large video,
280 290
     // minus the 36px space inside the remoteVideos container used for highlighting shadow.
281 291
     var availableHeight = window.innerHeight - $('#largeVideo').height() - 79;
282
-    var numvids = $('#remoteVideos>video:visible').length;
292
+    var numvids = $('#remoteVideos>span:visible').length;
283 293
     // Remove the 1px borders arround videos.
284 294
     var availableWinWidth = $('#remoteVideos').width() - 2 * numvids;
285 295
     var availableWidth = availableWinWidth / numvids;
@@ -290,9 +300,9 @@ function resizeThumbnails() {
290 300
         availableWidth = Math.floor(availableHeight * aspectRatio);
291 301
     }
292 302
     // size videos so that while keeping AR and max height, we have a nice fit
293
-    $('#remoteVideos').height(availableHeight + 36); // add the 2*18px border used for highlighting shadow.
294
-    $('#remoteVideos>video:visible').width(availableWidth);
295
-    $('#remoteVideos>video:visible').height(availableHeight);
303
+    $('#remoteVideos').height(availableHeight+26); // add the 2*18px-padding-top border used for highlighting shadow.
304
+    $('#remoteVideos>span').width(availableWidth);
305
+    $('#remoteVideos>span').height(availableHeight);
296 306
 }
297 307
 
298 308
 $(document).ready(function () {

+ 20
- 12
css/main.css Zobrazit soubor

@@ -16,14 +16,21 @@ html, body{
16 16
     float: left;
17 17
 }
18 18
 
19
-#largeVideo {
20
-    display:block;
21
-    position:relative;
22
-    width:1280px;
23
-    height:720px;
24
-    margin-left:auto;
25
-    margin-right:auto;
19
+.videocontainer {
20
+    position: relative;
21
+    margin-left: auto;
22
+    margin-right: auto;
23
+}
24
+.videocontainer>video {
25
+    position: absolute;
26
+    left: 0px;
27
+    top: 0px;
26 28
     z-index: 0;
29
+    width: 100%;
30
+    height: 100%;
31
+}
32
+
33
+#largeVideo {
27 34
 }
28 35
 
29 36
 #remoteVideos {
@@ -31,6 +38,7 @@ html, body{
31 38
     position:relative;
32 39
     text-align:center;
33 40
     height:196px;
41
+    padding-top:10px;
34 42
     width:auto;
35 43
     overflow: hidden;
36 44
     border:1px solid transparent;
@@ -38,16 +46,16 @@ html, body{
38 46
     z-index: 2;
39 47
 }
40 48
 
49
+#remoteVideos span {
50
+    display: inline-block;
51
+}
52
+
41 53
 #remoteVideos video {
42
-    position:relative;
43
-    top:18px;
44
-    height:160px;
45
-    width:auto;
46 54
     z-index:0;
47 55
     border:1px solid #FFFFFF;
48 56
 }
49 57
 
50
-#remoteVideos video:hover {
58
+#remoteVideos>span:hover {
51 59
     cursor: pointer;
52 60
     cursor: hand;
53 61
     transform:scale(1.08, 1.08);

+ 6
- 2
index.html Zobrazit soubor

@@ -43,10 +43,14 @@
43 43
 
44 44
     <div id="videospace">
45 45
         <div class="fade_line"></div>
46
-        <video id="largeVideo" autoplay oncontextmenu="return false;"></video>
46
+        <div class="videocontainer">
47
+          <video id="largeVideo" autoplay oncontextmenu="return false;"></video>
48
+        </div>
47 49
         <div class="fade_line"></div>
48 50
         <div id="remoteVideos">
49
-            <video id="localVideo" autoplay oncontextmenu="return false;" muted/>
51
+            <span id="localVideoContainer" class="videocontainer">
52
+              <video id="localVideo" autoplay oncontextmenu="return false;" muted/>
53
+            </span>
50 54
         </div>
51 55
     </div>
52 56
     <div id="chatspace">

Načítá se…
Zrušit
Uložit