Browse Source

Focuses clicked video thumbnail and prevents from switching to new large video.

master
paweldomas 11 years ago
parent
commit
8ba531ed22
3 changed files with 81 additions and 3 deletions
  1. 75
    1
      app.js
  2. 4
    0
      css/videolayout_default.css
  3. 2
    2
      data_channels.js

+ 75
- 1
app.js View File

15
  */
15
  */
16
 var ssrc2videoType = {};
16
 var ssrc2videoType = {};
17
 var videoSrcToSsrc = {};
17
 var videoSrcToSsrc = {};
18
+/**
19
+ * Currently focused video "src"(displayed in large video).
20
+ * @type {String}
21
+ */
22
+var focusedVideoSrc = null;
18
 var mutedAudios = {};
23
 var mutedAudios = {};
19
 
24
 
20
 var localVideoSrc = null;
25
 var localVideoSrc = null;
353
     }
358
     }
354
 });
359
 });
355
 
360
 
361
+/**
362
+ * Returns the JID of the user to whom given <tt>videoSrc</tt> belongs.
363
+ * @param videoSrc the video "src" identifier.
364
+ * @returns {null | String} the JID of the user to whom given <tt>videoSrc</tt>
365
+ *                   belongs.
366
+ */
367
+function getJidFromVideoSrc(videoSrc)
368
+{
369
+    if (videoSrc === localVideoSrc)
370
+        return connection.emuc.myroomjid;
371
+
372
+    var ssrc = videoSrcToSsrc[videoSrc];
373
+    if (!ssrc)
374
+    {
375
+        return null;
376
+    }
377
+    return ssrc2jid[ssrc];
378
+}
379
+
380
+/**
381
+ * Gets the selector of video thumbnail container for the user identified by
382
+ * given <tt>userJid</tt>
383
+ * @param userJid user's Jid for whom we want to get the video container.
384
+ */
385
+function getParticipantContainer(userJid)
386
+{
387
+    if (!userJid)
388
+        return null;
389
+
390
+    if (userJid === connection.emuc.myroomjid)
391
+        return $("#localVideoContainer");
392
+    else
393
+        return $("#participant_" + Strophe.getResourceFromJid(userJid));
394
+}
395
+
356
 function handleVideoThumbClicked(videoSrc) {
396
 function handleVideoThumbClicked(videoSrc) {
397
+    // Restore style for previously focused video
398
+    var oldContainer =
399
+        getParticipantContainer(
400
+            getJidFromVideoSrc(focusedVideoSrc));
401
+    if (oldContainer)
402
+        oldContainer.removeClass("videoContainerFocused");
403
+
404
+    // Unlock
405
+    if (focusedVideoSrc === videoSrc)
406
+    {
407
+        focusedVideoSrc = null;
408
+        return;
409
+    }
410
+
411
+    // Lock new video
412
+    focusedVideoSrc = videoSrc;
413
+
414
+    var userJid = getJidFromVideoSrc(videoSrc);
415
+    if (userJid)
416
+    {
417
+        var container = getParticipantContainer(userJid);
418
+        container.addClass("videoContainerFocused");
419
+    }
357
 
420
 
358
     $(document).trigger("video.selected", [false]);
421
     $(document).trigger("video.selected", [false]);
359
 
422
 
499
         videoelem.show();
562
         videoelem.show();
500
         resizeThumbnails();
563
         resizeThumbnails();
501
 
564
 
502
-        updateLargeVideo(videoelem.attr('src'), 1);
565
+        if (!focusedVideoSrc)
566
+            updateLargeVideo(videoelem.attr('src'), 1);
503
 
567
 
504
         showFocusIndicator();
568
         showFocusIndicator();
505
     }
569
     }
618
         }
682
         }
619
     }, 10);
683
     }, 10);
620
 
684
 
685
+    // Unlock large video
686
+    if (focusedVideoSrc)
687
+    {
688
+        if (getJidFromVideoSrc(focusedVideoSrc) === jid)
689
+        {
690
+            console.info("Focused video owner has left the conference");
691
+            focusedVideoSrc = null;
692
+        }
693
+    }
694
+
621
     connection.jingle.terminateByJid(jid);
695
     connection.jingle.terminateByJid(jid);
622
 
696
 
623
     if (focus == null
697
     if (focus == null

+ 4
- 0
css/videolayout_default.css View File

52
     z-index: 3;
52
     z-index: 3;
53
 }
53
 }
54
 
54
 
55
+#remoteVideos .videocontainer.videoContainerFocused {
56
+    border: 3px solid #388396;
57
+}
58
+
55
 #localVideoWrapper {
59
 #localVideoWrapper {
56
     display:inline-block;
60
     display:inline-block;
57
     -webkit-mask-box-image: url(../images/videomask.svg);
61
     -webkit-mask-box-image: url(../images/videomask.svg);

+ 2
- 2
data_channels.js View File

1
-/* global connection, Strophe, updateLargeVideo*/
1
+/* global connection, Strophe, updateLargeVideo, focusedVideoSrc*/
2
 /**
2
 /**
3
  * Callback triggered by PeerConnection when new data channel is opened
3
  * Callback triggered by PeerConnection when new data channel is opened
4
  * on the bridge.
4
  * on the bridge.
30
         console.info("Got Data Channel Message:", msgData, dataChannel);
30
         console.info("Got Data Channel Message:", msgData, dataChannel);
31
 
31
 
32
         // Active speaker event
32
         // Active speaker event
33
-        if (msgData.indexOf('activeSpeaker') === 0)
33
+        if (msgData.indexOf('activeSpeaker') === 0 && !focusedVideoSrc)
34
         {
34
         {
35
             // Endpoint ID from the bridge
35
             // Endpoint ID from the bridge
36
             var endpointId = msgData.split(":")[1];
36
             var endpointId = msgData.split(":")[1];

Loading…
Cancel
Save