|
@@ -138,8 +138,7 @@ var VideoLayout = (function (my) {
|
138
|
138
|
my.handleVideoThumbClicked = function(videoSrc) {
|
139
|
139
|
// Restore style for previously focused video
|
140
|
140
|
var focusJid = getJidFromVideoSrc(focusedVideoSrc);
|
141
|
|
- var oldContainer =
|
142
|
|
- getParticipantContainer(focusJid);
|
|
141
|
+ var oldContainer = getParticipantContainer(focusJid);
|
143
|
142
|
|
144
|
143
|
if (oldContainer) {
|
145
|
144
|
oldContainer.removeClass("videoContainerFocused");
|
|
@@ -147,12 +146,22 @@ var VideoLayout = (function (my) {
|
147
|
146
|
Strophe.getResourceFromJid(focusJid), false);
|
148
|
147
|
}
|
149
|
148
|
|
150
|
|
- // Unlock
|
|
149
|
+ // Unlock current focused.
|
151
|
150
|
if (focusedVideoSrc === videoSrc)
|
152
|
151
|
{
|
153
|
152
|
focusedVideoSrc = null;
|
|
153
|
+ // Enable the currently set active speaker.
|
|
154
|
+ if (currentActiveSpeaker) {
|
|
155
|
+ VideoLayout.enableActiveSpeaker(currentActiveSpeaker, true);
|
|
156
|
+ }
|
|
157
|
+
|
154
|
158
|
return;
|
155
|
159
|
}
|
|
160
|
+ // Remove style for current active speaker if we're going to lock
|
|
161
|
+ // another video.
|
|
162
|
+ else if (currentActiveSpeaker) {
|
|
163
|
+ VideoLayout.enableActiveSpeaker(currentActiveSpeaker, false);
|
|
164
|
+ }
|
156
|
165
|
|
157
|
166
|
// Lock new video
|
158
|
167
|
focusedVideoSrc = videoSrc;
|
|
@@ -526,7 +535,12 @@ var VideoLayout = (function (my) {
|
526
|
535
|
* disabled
|
527
|
536
|
*/
|
528
|
537
|
my.enableActiveSpeaker = function(resourceJid, isEnable) {
|
529
|
|
- console.log("Enable active speaker", resourceJid, isEnable);
|
|
538
|
+ var displayName = resourceJid;
|
|
539
|
+ var nameSpan = $('#participant_' + resourceJid + '>span.displayname');
|
|
540
|
+ if (nameSpan.length > 0)
|
|
541
|
+ displayName = nameSpan.text();
|
|
542
|
+
|
|
543
|
+ console.log("Enable active speaker", displayName, isEnable);
|
530
|
544
|
|
531
|
545
|
var videoSpanId = null;
|
532
|
546
|
if (resourceJid
|
|
@@ -542,21 +556,6 @@ var VideoLayout = (function (my) {
|
542
|
556
|
return;
|
543
|
557
|
}
|
544
|
558
|
|
545
|
|
- // If there's an active speaker (automatically) selected we have to
|
546
|
|
- // disable this state and update the current active speaker.
|
547
|
|
- if (isEnable) {
|
548
|
|
- if (currentActiveSpeaker) {
|
549
|
|
- var oldSpeaker = currentActiveSpeaker;
|
550
|
|
- setTimeout(function () {
|
551
|
|
- VideoLayout.enableActiveSpeaker(oldSpeaker, false);
|
552
|
|
- }, 200);
|
553
|
|
- }
|
554
|
|
-
|
555
|
|
- currentActiveSpeaker = resourceJid;
|
556
|
|
- }
|
557
|
|
- else if (resourceJid === currentActiveSpeaker)
|
558
|
|
- currentActiveSpeaker = null;
|
559
|
|
-
|
560
|
559
|
var video = $('#' + videoSpanId + '>video');
|
561
|
560
|
|
562
|
561
|
if (video && video.length > 0) {
|
|
@@ -733,6 +732,13 @@ var VideoLayout = (function (my) {
|
733
|
732
|
}
|
734
|
733
|
};
|
735
|
734
|
|
|
735
|
+ /**
|
|
736
|
+ * Returns the current active speaker.
|
|
737
|
+ */
|
|
738
|
+ my.getActiveSpeakerContainerId = function () {
|
|
739
|
+ return 'participant_' + currentActiveSpeaker;
|
|
740
|
+ };
|
|
741
|
+
|
736
|
742
|
/**
|
737
|
743
|
* Adds the remote video menu element for the given <tt>jid</tt> in the
|
738
|
744
|
* given <tt>parentElement</tt>.
|
|
@@ -841,5 +847,45 @@ var VideoLayout = (function (my) {
|
841
|
847
|
VideoLayout.showVideoIndicator(videoSpanId, isMuted);
|
842
|
848
|
});
|
843
|
849
|
|
|
850
|
+ /**
|
|
851
|
+ * On active speaker changed event.
|
|
852
|
+ */
|
|
853
|
+ $(document).bind('activespeakerchanged', function (event, resourceJid) {
|
|
854
|
+
|
|
855
|
+ // Disable style for previous active speaker.
|
|
856
|
+ if (currentActiveSpeaker
|
|
857
|
+ && currentActiveSpeaker !== resourceJid
|
|
858
|
+ && !focusedVideoSrc) {
|
|
859
|
+ var oldContainer = document.getElementById(
|
|
860
|
+ 'participant_' + currentActiveSpeaker);
|
|
861
|
+
|
|
862
|
+ if (oldContainer) {
|
|
863
|
+ VideoLayout.enableActiveSpeaker(currentActiveSpeaker, false);
|
|
864
|
+ }
|
|
865
|
+ }
|
|
866
|
+
|
|
867
|
+ // Obtain container for new active speaker.
|
|
868
|
+ var container = document.getElementById(
|
|
869
|
+ 'participant_' + resourceJid);
|
|
870
|
+
|
|
871
|
+ // Update the current active speaker.
|
|
872
|
+ if (resourceJid !== currentActiveSpeaker)
|
|
873
|
+ currentActiveSpeaker = resourceJid;
|
|
874
|
+ else
|
|
875
|
+ return;
|
|
876
|
+
|
|
877
|
+ // Local video will not have container found, but that's ok
|
|
878
|
+ // since we don't want to switch to local video.
|
|
879
|
+ if (container && !focusedVideoSrc)
|
|
880
|
+ {
|
|
881
|
+ var video = container.getElementsByTagName("video");
|
|
882
|
+ if (video.length)
|
|
883
|
+ {
|
|
884
|
+ VideoLayout.updateLargeVideo(video[0].src);
|
|
885
|
+ VideoLayout.enableActiveSpeaker(resourceJid, true);
|
|
886
|
+ }
|
|
887
|
+ }
|
|
888
|
+ });
|
|
889
|
+
|
844
|
890
|
return my;
|
845
|
891
|
}(VideoLayout || {}));
|