Browse Source

Allows hovering local video. Fixes hover over remote videos.

j8
Yana Stamcheva 11 years ago
parent
commit
d414e037be
3 changed files with 46 additions and 48 deletions
  1. 39
    38
      app.js
  2. 0
    3
      css/main.css
  3. 7
    7
      index.html

+ 39
- 38
app.js View File

@@ -9,7 +9,7 @@ var sharedKey = '';
9 9
 var roomUrl = null;
10 10
 var ssrc2jid = {};
11 11
 
12
-window.onbeforeunload = closePageWarning;
12
+/* window.onbeforeunload = closePageWarning; */
13 13
 
14 14
 function init() {
15 15
     RTC = setupRTC();
@@ -93,8 +93,12 @@ $(document).bind('mediaready.jingle', function (event, stream) {
93 93
     document.getElementById('localVideo').autoplay = true;
94 94
     document.getElementById('localVideo').volume = 0;
95 95
 
96
-    document.getElementById('largeVideo').volume = 0;
97
-    document.getElementById('largeVideo').src = document.getElementById('localVideo').src;
96
+    updateLargeVideo(document.getElementById('localVideo').src, true);
97
+
98
+    $('#localVideo').click(function () {
99
+        updateLargeVideo($(this).attr('src'), true);
100
+    });
101
+
98 102
     doJoin();
99 103
 });
100 104
 
@@ -121,7 +125,7 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
121 125
         var ssrclines = SDPUtil.find_lines(sess.peerconnection.remoteDescription.sdp, 'a=ssrc');
122 126
         ssrclines = ssrclines.filter(function (line) {
123 127
             return line.indexOf('mslabel:' + data.stream.label) != -1; 
124
-        })
128
+                                     });
125 129
         if (ssrclines.length) {
126 130
             thessrc = ssrclines[0].substring(7).split(' ')[0];
127 131
             // ok to overwrite the one from focus? might save work in colibri.js
@@ -175,15 +179,7 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
175 179
     };
176 180
     sel.click(
177 181
         function () {
178
-            console.log('hover in', $(this).attr('src'));
179
-            var newSrc = $(this).attr('src');
180
-            if ($('#largeVideo').attr('src') != newSrc) {
181
-                document.getElementById('largeVideo').volume = 1;
182
-                $('#largeVideo').fadeOut(300, function () {
183
-                    $(this).attr('src', newSrc);
184
-                    $(this).fadeIn(300);
185
-                });
186
-            }
182
+            updateLargeVideo($(this).attr('src'), false);
187 183
         }
188 184
     );
189 185
 });
@@ -263,6 +259,7 @@ $(document).bind('entered.muc', function (event, jid, info, pres) {
263 259
     else if (sharedKey) {
264 260
         updateLockButton();
265 261
     }
262
+
266 263
     $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
267 264
         //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
268 265
         ssrc2jid[ssrc.getAttribute('ssrc')] = jid;
@@ -287,36 +284,13 @@ $(document).bind('left.muc', function (event, jid) {
287 284
     }
288 285
 });
289 286
 
290
-$(document).bind('passwordrequired.muc', function (event, jid) {
291
-    console.log('on password required', jid);
292
-
293
-    $.prompt('<h2>Password required</h2>' +
294
-            '<input id="lockKey" type="text" placeholder="shared key" autofocus>',
295
-             {
296
-                persistent: true,
297
-                buttons: { "Ok": true , "Cancel": false},
298
-                defaultButton: 1,
299
-                loaded: function(event) {
300
-                    document.getElementById('lockKey').focus();
301
-                },
302
-                submit: function(e,v,m,f){
303
-                    if(v)
304
-                    {
305
-                        var lockKey = document.getElementById('lockKey');
306
-
307
-                        if (lockKey.value != null)
308
-                        {
309
-                            setSharedKey(lockKey);
310
-                            connection.emuc.doJoin(jid, lockKey.value);
311
-                        }
312
-                    }
313
-                }
314
-            });
315 287
 $(document).bind('presence.muc', function (event, jid, info, pres) {
316 288
     $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
317 289
         //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
318 290
         ssrc2jid[ssrc.getAttribute('ssrc')] = jid;
319 291
     });
292
+});
293
+
320 294
 $(document).bind('passwordrequired.muc', function (event, jid) {
321 295
     console.log('on password required', jid);
322 296
 
@@ -344,6 +318,33 @@ $(document).bind('passwordrequired.muc', function (event, jid) {
344 318
             });
345 319
 });
346 320
 
321
+/**
322
+ * Updates the large video with the given new video source.
323
+ */
324
+function updateLargeVideo(newSrc, localVideo) {
325
+    console.log('hover in', newSrc);
326
+    if ($('#largeVideo').attr('src') != newSrc) {
327
+        if (!localVideo)
328
+            document.getElementById('largeVideo').volume = 1;
329
+        else
330
+            document.getElementById('largeVideo').volume = 0;
331
+
332
+        $('#largeVideo').fadeOut(300, function () {
333
+            $(this).attr('src', newSrc);
334
+
335
+            var videoTransform = document.getElementById('largeVideo').style.webkitTransform;
336
+            if (localVideo && videoTransform != 'scaleX(-1)') {
337
+                document.getElementById('largeVideo').style.webkitTransform = "scaleX(-1)";
338
+            }
339
+            else if (!localVideo && videoTransform == 'scaleX(-1)') {
340
+                document.getElementById('largeVideo').style.webkitTransform = "none";
341
+            }
342
+
343
+            $(this).fadeIn(300);
344
+        });
345
+    }
346
+}
347
+
347 348
 function toggleVideo() {
348 349
     if (!(connection && connection.jingle.localStream)) return;
349 350
     for (var idx = 0; idx < connection.jingle.localStream.getVideoTracks().length; idx++) {

+ 0
- 3
css/main.css View File

@@ -55,9 +55,6 @@ html, body{
55 55
 
56 56
 #remoteVideos span {
57 57
     display: inline-block;
58
-}
59
-
60
-#remoteVideos video {
61 58
     z-index:0;
62 59
     border:1px solid #FFFFFF;
63 60
 }

+ 7
- 7
index.html View File

@@ -2,15 +2,15 @@
2 2
   <head>
3 3
     <title>WebRTC, meet the Jitsi Videobridge</title>
4 4
     <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
5
-    <script src="libs/strophejingle.bundle.js?v=2"></script><!-- strophe.jingle bundle -->
6
-    <script src="libs/colibri.js?v=2"></script><!-- colibri focus implementation -->
7
-    <script src="muc.js?v=2"></script><!-- simple MUC library -->
5
+    <script src="libs/strophejingle.bundle.js?v=3"></script><!-- strophe.jingle bundle -->
6
+    <script src="libs/colibri.js?v=3"></script><!-- colibri focus implementation -->
7
+    <script src="muc.js?v=3"></script><!-- simple MUC library -->
8 8
     <script src="estos_log.js?v=1"></script><!-- simple stanza logger -->
9
-    <script src="app.js?v=2"></script><!-- application logic -->
9
+    <script src="app.js?v=3"></script><!-- application logic -->
10 10
     <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
11
-    <link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=2"/>
12
-    <link rel="stylesheet" href="css/jquery-impromptu.css?v=1">
13
-    <link rel="stylesheet" href="css/modaldialog.css?v=1">
11
+    <link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=3"/>
12
+    <link rel="stylesheet" href="css/jquery-impromptu.css?v=2">
13
+    <link rel="stylesheet" href="css/modaldialog.css?v=2">
14 14
     <script src="libs/jquery-impromptu.js"></script>
15 15
     <script src="libs/jquery.autosize.js"></script>
16 16
     <script src="config.js"></script><!-- adapt to your needs, i.e. set hosts and bosh path -->

Loading…
Cancel
Save