瀏覽代碼

Switches to the last visible video correctly when current speaker leaves the conference.

j8
paweldomas 9 年之前
父節點
當前提交
4aa6fbc4b9
共有 3 個文件被更改,包括 32 次插入27 次删除
  1. 2
    15
      modules/UI/UI.js
  2. 6
    0
      modules/UI/videolayout/LargeVideo.js
  3. 24
    12
      modules/UI/videolayout/VideoLayout.js

+ 2
- 15
modules/UI/UI.js 查看文件

@@ -546,23 +546,10 @@ function onMucMemberLeft(jid) {
546 546
     if(!config.startAudioMuted ||
547 547
         config.startAudioMuted > APP.members.size())
548 548
         UIUtil.playSoundNotification('userLeft');
549
-    // Need to call this with a slight delay, otherwise the element couldn't be
550
-    // found for some reason.
551
-    // XXX(gp) it works fine without the timeout for me (with Chrome 38).
552
-    window.setTimeout(function () {
553
-        var container = document.getElementById(
554
-                'participant_' + Strophe.getResourceFromJid(jid));
555
-        if (container) {
556
-            ContactList.removeContact(jid);
557
-            VideoLayout.removeConnectionIndicator(jid);
558
-            // hide here, wait for video to close before removing
559
-            $(container).hide();
560
-            VideoLayout.resizeThumbnails();
561
-        }
562
-    }, 10);
563 549
 
564
-    VideoLayout.participantLeft(jid);
550
+    ContactList.removeContact(jid);
565 551
 
552
+    VideoLayout.participantLeft(jid);
566 553
 };
567 554
 
568 555
 

+ 6
- 0
modules/UI/videolayout/LargeVideo.js 查看文件

@@ -205,6 +205,12 @@ function updateActiveSpeakerAvatarSrc() {
205 205
 }
206 206
 
207 207
 function changeVideo(isVisible) {
208
+
209
+    if (!currentSmallVideo) {
210
+        console.error("Unable to change large video - no 'currentSmallVideo'");
211
+        return;
212
+    }
213
+
208 214
     updateActiveSpeakerAvatarSrc();
209 215
 
210 216
     APP.RTC.setVideoSrc($('#largeVideo')[0], currentSmallVideo.getSrc());

+ 24
- 12
modules/UI/videolayout/VideoLayout.js 查看文件

@@ -119,7 +119,8 @@ var VideoLayout = (function (my) {
119 119
             var newResourceJid;
120 120
             // We'll show user's avatar if he is the dominant speaker or if
121 121
             // his video thumbnail is pinned
122
-            if (resourceJid === focusedVideoResourceJid ||
122
+            if (remoteVideos[resourceJid] &&
123
+                resourceJid === focusedVideoResourceJid ||
123 124
                 resourceJid === currentDominantSpeaker) {
124 125
                 newResourceJid = resourceJid;
125 126
             } else {
@@ -137,18 +138,20 @@ var VideoLayout = (function (my) {
137 138
         var videoElem = RTC.getVideoElementName();
138 139
         var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last>' + videoElem);
139 140
         if (pick.length && APP.RTC.getVideoSrc(pick[0])) {
140
-            return VideoLayout.getPeerContainerResourceJid(pick[0].parentNode);
141
+            jid = VideoLayout.getPeerContainerResourceJid(pick[0].parentNode);
141 142
         } else {
142 143
             console.info("Last visible video no longer exists");
143 144
             pick = $('#remoteVideos>span[id!="mixedstream"]>' + videoElem);
144 145
             if (pick.length && APP.RTC.getVideoSrc(pick[0])) {
145
-                return VideoLayout.getPeerContainerResourceJid(pick[0].parentNode);
146
+                jid = VideoLayout.getPeerContainerResourceJid(pick[0].parentNode);
146 147
             } else {
147 148
                 // Try local video
148 149
                 console.info("Fallback to local video...");
149
-                return APP.xmpp.myResource();
150
+                jid = APP.xmpp.myResource();
150 151
             }
151 152
         }
153
+        console.info("electLastVisibleVideo: " + jid);
154
+        return jid;
152 155
     };
153 156
     
154 157
     my.onRemoteStreamAdded = function (stream) {
@@ -784,14 +787,6 @@ var VideoLayout = (function (my) {
784 787
             remoteVideos[resourceJid].updateStatsIndicator(percent, object);
785 788
     };
786 789
 
787
-    /**
788
-     * Removes the connection
789
-     * @param jid
790
-     */
791
-    my.removeConnectionIndicator = function (jid) {
792
-        remoteVideos[Strophe.getResourceFromJid(jid)].removeConnectionIndicator();
793
-    };
794
-
795 790
     /**
796 791
      * Hides the connection indicator
797 792
      * @param jid
@@ -819,6 +814,23 @@ var VideoLayout = (function (my) {
819 814
             console.info("Focused video owner has left the conference");
820 815
             focusedVideoResourceJid = null;
821 816
         }
817
+
818
+        if (currentDominantSpeaker === resourceJid)
819
+        {
820
+            console.info("Dominant speaker has left the conference");
821
+            currentDominantSpeaker = null;
822
+        }
823
+
824
+        var remoteVideo = remoteVideos[resourceJid];
825
+        if (remoteVideo) {
826
+            remoteVideo.removeConnectionIndicator();
827
+            // Remove remote video
828
+            delete remoteVideos[resourceJid];
829
+        } else {
830
+            console.warn("No remote video for " + resourceJid);
831
+        }
832
+
833
+        VideoLayout.resizeThumbnails();
822 834
     };
823 835
     
824 836
     my.onVideoTypeChanged = function (jid) {

Loading…
取消
儲存