Browse Source

move video elements into container elements

master
Philipp Hancke 11 years ago
parent
commit
ab1ac06e83
3 changed files with 45 additions and 23 deletions
  1. 19
    9
      app.js
  2. 20
    12
      css/main.css
  3. 6
    2
      index.html

+ 19
- 9
app.js View File

96
     }
96
     }
97
     var sess = connection.jingle.sessions[sid];
97
     var sess = connection.jingle.sessions[sid];
98
     var vid = document.createElement('video');
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
     var id = 'remoteVideo_' + sid + '_' + data.stream.id;
105
     var id = 'remoteVideo_' + sid + '_' + data.stream.id;
100
     vid.id = id;
106
     vid.id = id;
101
     vid.autoplay = true;
107
     vid.autoplay = true;
102
     vid.oncontextmenu = function () { return false; };
108
     vid.oncontextmenu = function () { return false; };
103
     var remotes = document.getElementById('remoteVideos');
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
     var sel = $('#' + id);
115
     var sel = $('#' + id);
106
     sel.hide();
116
     sel.hide();
107
     RTC.attachMediaStream(sel, data.stream);
117
     RTC.attachMediaStream(sel, data.stream);
109
     data.stream.onended = function () {
119
     data.stream.onended = function () {
110
         console.log('stream ended', this.id);
120
         console.log('stream ended', this.id);
111
         var src = $('#' + id).attr('src');
121
         var src = $('#' + id).attr('src');
112
-        $('#' + id).remove();
122
+        $('#' + id).parent().remove();
113
         if (src === $('#largeVideo').attr('src')) {
123
         if (src === $('#largeVideo').attr('src')) {
114
             // this is currently displayed as large
124
             // this is currently displayed as large
115
             // pick the last visible video in the row
125
             // pick the last visible video in the row
116
             // if nobody else is left, this picks the local video
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
             // mute if localvideo
128
             // mute if localvideo
119
             document.getElementById('largeVideo').volume = pick.volume;
129
             document.getElementById('largeVideo').volume = pick.volume;
120
             document.getElementById('largeVideo').src = pick.src;
130
             document.getElementById('largeVideo').src = pick.src;
269
         availableWidth = Math.floor(availableHeight * aspectRatio);
279
         availableWidth = Math.floor(availableHeight * aspectRatio);
270
     }
280
     }
271
     if (availableWidth < 0 || availableHeight < 0) return;
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
     resizeThumbnails();
284
     resizeThumbnails();
275
 }
285
 }
276
 
286
 
279
     // minus 4px for the delimiter lines on the top and bottom of the large video,
289
     // minus 4px for the delimiter lines on the top and bottom of the large video,
280
     // minus the 36px space inside the remoteVideos container used for highlighting shadow.
290
     // minus the 36px space inside the remoteVideos container used for highlighting shadow.
281
     var availableHeight = window.innerHeight - $('#largeVideo').height() - 79;
291
     var availableHeight = window.innerHeight - $('#largeVideo').height() - 79;
282
-    var numvids = $('#remoteVideos>video:visible').length;
292
+    var numvids = $('#remoteVideos>span:visible').length;
283
     // Remove the 1px borders arround videos.
293
     // Remove the 1px borders arround videos.
284
     var availableWinWidth = $('#remoteVideos').width() - 2 * numvids;
294
     var availableWinWidth = $('#remoteVideos').width() - 2 * numvids;
285
     var availableWidth = availableWinWidth / numvids;
295
     var availableWidth = availableWinWidth / numvids;
290
         availableWidth = Math.floor(availableHeight * aspectRatio);
300
         availableWidth = Math.floor(availableHeight * aspectRatio);
291
     }
301
     }
292
     // size videos so that while keeping AR and max height, we have a nice fit
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
 $(document).ready(function () {
308
 $(document).ready(function () {

+ 20
- 12
css/main.css View File

16
     float: left;
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
     z-index: 0;
28
     z-index: 0;
29
+    width: 100%;
30
+    height: 100%;
31
+}
32
+
33
+#largeVideo {
27
 }
34
 }
28
 
35
 
29
 #remoteVideos {
36
 #remoteVideos {
31
     position:relative;
38
     position:relative;
32
     text-align:center;
39
     text-align:center;
33
     height:196px;
40
     height:196px;
41
+    padding-top:10px;
34
     width:auto;
42
     width:auto;
35
     overflow: hidden;
43
     overflow: hidden;
36
     border:1px solid transparent;
44
     border:1px solid transparent;
38
     z-index: 2;
46
     z-index: 2;
39
 }
47
 }
40
 
48
 
49
+#remoteVideos span {
50
+    display: inline-block;
51
+}
52
+
41
 #remoteVideos video {
53
 #remoteVideos video {
42
-    position:relative;
43
-    top:18px;
44
-    height:160px;
45
-    width:auto;
46
     z-index:0;
54
     z-index:0;
47
     border:1px solid #FFFFFF;
55
     border:1px solid #FFFFFF;
48
 }
56
 }
49
 
57
 
50
-#remoteVideos video:hover {
58
+#remoteVideos>span:hover {
51
     cursor: pointer;
59
     cursor: pointer;
52
     cursor: hand;
60
     cursor: hand;
53
     transform:scale(1.08, 1.08);
61
     transform:scale(1.08, 1.08);

+ 6
- 2
index.html View File

43
 
43
 
44
     <div id="videospace">
44
     <div id="videospace">
45
         <div class="fade_line"></div>
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
         <div class="fade_line"></div>
49
         <div class="fade_line"></div>
48
         <div id="remoteVideos">
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
         </div>
54
         </div>
51
     </div>
55
     </div>
52
     <div id="chatspace">
56
     <div id="chatspace">

Loading…
Cancel
Save