Parcourir la source

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

j8
Yana Stamcheva il y a 12 ans
Parent
révision
3556c867f4
3 fichiers modifiés avec 46 ajouts et 47 suppressions
  1. 32
    45
      app.js
  2. 11
    0
      css/main.css
  3. 3
    2
      index.html

+ 32
- 45
app.js Voir le fichier

8
 var sharedKey = '';
8
 var sharedKey = '';
9
 var roomUrl = null;
9
 var roomUrl = null;
10
 var ssrc2jid = {};
10
 var ssrc2jid = {};
11
+var localVideoSrc = null;
11
 
12
 
12
 /* window.onbeforeunload = closePageWarning; */
13
 /* window.onbeforeunload = closePageWarning; */
13
 
14
 
93
     document.getElementById('localVideo').autoplay = true;
94
     document.getElementById('localVideo').autoplay = true;
94
     document.getElementById('localVideo').volume = 0;
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
     $('#localVideo').click(function () {
100
     $('#localVideo').click(function () {
99
-        updateLargeVideo($(this).attr('src'), true);
101
+        updateLargeVideo($(this).attr('src'), true, 1);
100
     });
102
     });
101
 
103
 
102
     doJoin();
104
     doJoin();
184
             // if nobody else is left, this picks the local video
186
             // if nobody else is left, this picks the local video
185
             var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last>video').get(0);
187
             var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last>video').get(0);
186
             // mute if localvideo
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
         $('#' + id).parent().remove();
195
         $('#' + id).parent().remove();
191
         resizeThumbnails();
196
         resizeThumbnails();
192
     };
197
     };
193
     sel.click(
198
     sel.click(
194
         function () {
199
         function () {
195
-            updateLargeVideo($(this).attr('src'), false);
200
+            updateLargeVideo($(this).attr('src'), false, 1);
196
         }
201
         }
197
     );
202
     );
198
 });
203
 });
211
         videoelem.show();
216
         videoelem.show();
212
         resizeThumbnails();
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
         updateLockButton();
290
         updateLockButton();
287
     }
291
     }
288
 
292
 
293
+    showFocusIndicator();
294
+
289
     $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
295
     $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
290
         //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
296
         //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
291
         ssrc2jid[ssrc.getAttribute('ssrc')] = jid;
297
         ssrc2jid[ssrc.getAttribute('ssrc')] = jid;
352
 /**
358
 /**
353
  * Updates the large video with the given new video source.
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
     console.log('hover in', newSrc);
362
     console.log('hover in', newSrc);
357
     if ($('#largeVideo').attr('src') != newSrc) {
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
         $('#largeVideo').fadeOut(300, function () {
367
         $('#largeVideo').fadeOut(300, function () {
364
             $(this).attr('src', newSrc);
368
             $(this).attr('src', newSrc);
528
     return false;
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
  * Appends the given message to the chat conversation.
536
  * Appends the given message to the chat conversation.
566
  */
537
  */
735
     else
706
     else
736
         return "You are about to leave this conversation.";
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 Voir le fichier

347
     z-index: 100;
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 Voir le fichier

49
         <div class="fade_line"></div>
49
         <div class="fade_line"></div>
50
         <div id="remoteVideos">
50
         <div id="remoteVideos">
51
             <span id="localVideoContainer" class="videocontainer">
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
             </span>
55
             </span>
55
         </div>
56
         </div>
56
     </div>
57
     </div>

Chargement…
Annuler
Enregistrer