Browse Source

Fixes mute when selecting local video. Adds an indicator when we're the focus. Fixes flip on remote videos.

j8
Yana Stamcheva 11 years ago
parent
commit
3556c867f4
3 changed files with 46 additions and 47 deletions
  1. 32
    45
      app.js
  2. 11
    0
      css/main.css
  3. 3
    2
      index.html

+ 32
- 45
app.js View File

@@ -8,6 +8,7 @@ var nickname = null;
8 8
 var sharedKey = '';
9 9
 var roomUrl = null;
10 10
 var ssrc2jid = {};
11
+var localVideoSrc = null;
11 12
 
12 13
 /* window.onbeforeunload = closePageWarning; */
13 14
 
@@ -93,10 +94,11 @@ $(document).bind('mediaready.jingle', function (event, stream) {
93 94
     document.getElementById('localVideo').autoplay = true;
94 95
     document.getElementById('localVideo').volume = 0;
95 96
 
96
-    updateLargeVideo(document.getElementById('localVideo').src, true);
97
+    localVideoSrc = document.getElementById('localVideo').src;
98
+    updateLargeVideo(localVideoSrc, true, 0);
97 99
 
98 100
     $('#localVideo').click(function () {
99
-        updateLargeVideo($(this).attr('src'), true);
101
+        updateLargeVideo($(this).attr('src'), true, 1);
100 102
     });
101 103
 
102 104
     doJoin();
@@ -184,15 +186,18 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
184 186
             // if nobody else is left, this picks the local video
185 187
             var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last>video').get(0);
186 188
             // mute if localvideo
187
-            document.getElementById('largeVideo').volume = pick.volume;
188
-            document.getElementById('largeVideo').src = pick.src;
189
+            var isLocalVideo = false;
190
+            if (pick.src === localVideoSrc)
191
+                 isLocalVideo = true;
192
+
193
+            updateLargeVideo(pick.src, isLocalVideo, pick.volume);
189 194
         }
190 195
         $('#' + id).parent().remove();
191 196
         resizeThumbnails();
192 197
     };
193 198
     sel.click(
194 199
         function () {
195
-            updateLargeVideo($(this).attr('src'), false);
200
+            updateLargeVideo($(this).attr('src'), false, 1);
196 201
         }
197 202
     );
198 203
 });
@@ -211,8 +216,7 @@ $(document).bind('callactive.jingle', function (event, videoelem, sid) {
211 216
         videoelem.show();
212 217
         resizeThumbnails();
213 218
 
214
-        document.getElementById('largeVideo').volume = 1;
215
-        $('#largeVideo').attr('src', videoelem.attr('src'));
219
+        updateLargeVideo(videoelem.attr('src'), false, 1);
216 220
     }
217 221
 });
218 222
 
@@ -286,6 +290,8 @@ $(document).bind('entered.muc', function (event, jid, info, pres) {
286 290
         updateLockButton();
287 291
     }
288 292
 
293
+    showFocusIndicator();
294
+
289 295
     $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
290 296
         //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
291 297
         ssrc2jid[ssrc.getAttribute('ssrc')] = jid;
@@ -352,13 +358,11 @@ $(document).bind('passwordrequired.muc', function (event, jid) {
352 358
 /**
353 359
  * Updates the large video with the given new video source.
354 360
  */
355
-function updateLargeVideo(newSrc, localVideo) {
361
+function updateLargeVideo(newSrc, localVideo, vol) {
356 362
     console.log('hover in', newSrc);
357 363
     if ($('#largeVideo').attr('src') != newSrc) {
358
-        if (!localVideo)
359
-            document.getElementById('largeVideo').volume = 1;
360
-        else
361
-            document.getElementById('largeVideo').volume = 0;
364
+
365
+        document.getElementById('largeVideo').volume = vol;
362 366
 
363 367
         $('#largeVideo').fadeOut(300, function () {
364 368
             $(this).attr('src', newSrc);
@@ -528,39 +532,6 @@ function dump(elem, filename){
528 532
     return false;
529 533
 }
530 534
 
531
-/*
532
- * Appends the given message to the chat conversation.
533
- */
534
-// <a onclick="dump(event.target);">my download button</a>
535
-function dump(elem, filename){
536
-    elem = elem.parentNode;
537
-    elem.download = filename || 'meetlog.json';
538
-    elem.href = 'data:application/json;charset=utf-8,\n';
539
-    var data = {};
540
-    if (connection.jingle) {
541
-        Object.keys(connection.jingle.sessions).forEach(function (sid) {
542
-            var session = connection.jingle.sessions[sid];
543
-            if (session.peerconnection && session.peerconnection.updateLog) {
544
-                // FIXME: should probably be a .dump call
545
-                data["jingle_" + session.sid] = {
546
-                    updateLog: session.peerconnection.updateLog,
547
-                    url: window.location.href}
548
-                ;
549
-            }
550
-        });
551
-    }
552
-    metadata = {};
553
-    metadata.time = new Date();
554
-    metadata.url = window.location.href;
555
-    metadata.ua = navigator.userAgent;
556
-    if (connection.logger) {
557
-        metadata.xmpp = connection.logger.log;
558
-    }
559
-    data.metadata = metadata;
560
-    elem.href += encodeURIComponent(JSON.stringify(data, null, '  '));
561
-    return false;
562
-}
563
-
564 535
 /*
565 536
  * Appends the given message to the chat conversation.
566 537
  */
@@ -735,3 +706,19 @@ function closePageWarning() {
735 706
     else
736 707
         return "You are about to leave this conversation.";
737 708
 }
709
+
710
+/*
711
+ * Shows a visual indicator for the focus of the conference.
712
+ */
713
+function showFocusIndicator() {
714
+    if (focus !== null) {
715
+        var localVideoToolbar = document.getElementById('localVideoToolbar');
716
+
717
+        var focusIndicator = document.createElement('i');
718
+        focusIndicator.className = 'fa fa-star';
719
+        localVideoToolbar.appendChild(focusIndicator);
720
+    }
721
+    else {
722
+//        console.log("FOCUS JID", connection.jingle.sessions[Object.keys(connection.jingle.sessions)].peerjid);
723
+    }
724
+}

+ 11
- 0
css/main.css View File

@@ -347,3 +347,14 @@ form {
347 347
     z-index: 100;
348 348
 }
349 349
 
350
+.videocontainer>span.focusindicator {
351
+    display: inline-block;
352
+    position: absolute;
353
+    color: #FFFFFF;
354
+    top: 0;
355
+    padding: 5px 0px;
356
+    width: 25px;
357
+    font-size: 11pt;
358
+    text-shadow: 0px 1px 0px rgba(255,255,255,.3), 0px -1px 0px rgba(0,0,0,.7);
359
+    border: 0px;
360
+}

+ 3
- 2
index.html View File

@@ -49,8 +49,9 @@
49 49
         <div class="fade_line"></div>
50 50
         <div id="remoteVideos">
51 51
             <span id="localVideoContainer" class="videocontainer">
52
-              <span id="localNick"></span>
53
-              <video id="localVideo" autoplay oncontextmenu="return false;" muted/>
52
+                <span id="localNick"></span>
53
+                <video id="localVideo" autoplay oncontextmenu="return false;" muted></video>
54
+                <span id="localVideoToolbar" class="focusindicator"></span>
54 55
             </span>
55 56
         </div>
56 57
     </div>

Loading…
Cancel
Save