Browse Source

Allows hovering local video. Fixes hover over remote videos.

j8
Yana Stamcheva 12 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
 var roomUrl = null;
9
 var roomUrl = null;
10
 var ssrc2jid = {};
10
 var ssrc2jid = {};
11
 
11
 
12
-window.onbeforeunload = closePageWarning;
12
+/* window.onbeforeunload = closePageWarning; */
13
 
13
 
14
 function init() {
14
 function init() {
15
     RTC = setupRTC();
15
     RTC = setupRTC();
93
     document.getElementById('localVideo').autoplay = true;
93
     document.getElementById('localVideo').autoplay = true;
94
     document.getElementById('localVideo').volume = 0;
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
     doJoin();
102
     doJoin();
99
 });
103
 });
100
 
104
 
121
         var ssrclines = SDPUtil.find_lines(sess.peerconnection.remoteDescription.sdp, 'a=ssrc');
125
         var ssrclines = SDPUtil.find_lines(sess.peerconnection.remoteDescription.sdp, 'a=ssrc');
122
         ssrclines = ssrclines.filter(function (line) {
126
         ssrclines = ssrclines.filter(function (line) {
123
             return line.indexOf('mslabel:' + data.stream.label) != -1; 
127
             return line.indexOf('mslabel:' + data.stream.label) != -1; 
124
-        })
128
+                                     });
125
         if (ssrclines.length) {
129
         if (ssrclines.length) {
126
             thessrc = ssrclines[0].substring(7).split(' ')[0];
130
             thessrc = ssrclines[0].substring(7).split(' ')[0];
127
             // ok to overwrite the one from focus? might save work in colibri.js
131
             // ok to overwrite the one from focus? might save work in colibri.js
175
     };
179
     };
176
     sel.click(
180
     sel.click(
177
         function () {
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
     else if (sharedKey) {
259
     else if (sharedKey) {
264
         updateLockButton();
260
         updateLockButton();
265
     }
261
     }
262
+
266
     $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
263
     $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
267
         //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
264
         //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
268
         ssrc2jid[ssrc.getAttribute('ssrc')] = jid;
265
         ssrc2jid[ssrc.getAttribute('ssrc')] = 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
 $(document).bind('presence.muc', function (event, jid, info, pres) {
287
 $(document).bind('presence.muc', function (event, jid, info, pres) {
316
     $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
288
     $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
317
         //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
289
         //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
318
         ssrc2jid[ssrc.getAttribute('ssrc')] = jid;
290
         ssrc2jid[ssrc.getAttribute('ssrc')] = jid;
319
     });
291
     });
292
+});
293
+
320
 $(document).bind('passwordrequired.muc', function (event, jid) {
294
 $(document).bind('passwordrequired.muc', function (event, jid) {
321
     console.log('on password required', jid);
295
     console.log('on password required', jid);
322
 
296
 
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
 function toggleVideo() {
348
 function toggleVideo() {
348
     if (!(connection && connection.jingle.localStream)) return;
349
     if (!(connection && connection.jingle.localStream)) return;
349
     for (var idx = 0; idx < connection.jingle.localStream.getVideoTracks().length; idx++) {
350
     for (var idx = 0; idx < connection.jingle.localStream.getVideoTracks().length; idx++) {

+ 0
- 3
css/main.css View File

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

+ 7
- 7
index.html View File

2
   <head>
2
   <head>
3
     <title>WebRTC, meet the Jitsi Videobridge</title>
3
     <title>WebRTC, meet the Jitsi Videobridge</title>
4
     <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
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
     <script src="estos_log.js?v=1"></script><!-- simple stanza logger -->
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
     <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
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
     <script src="libs/jquery-impromptu.js"></script>
14
     <script src="libs/jquery-impromptu.js"></script>
15
     <script src="libs/jquery.autosize.js"></script>
15
     <script src="libs/jquery.autosize.js"></script>
16
     <script src="config.js"></script><!-- adapt to your needs, i.e. set hosts and bosh path -->
16
     <script src="config.js"></script><!-- adapt to your needs, i.e. set hosts and bosh path -->

Loading…
Cancel
Save