瀏覽代碼

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
     if(!config.startAudioMuted ||
546
     if(!config.startAudioMuted ||
547
         config.startAudioMuted > APP.members.size())
547
         config.startAudioMuted > APP.members.size())
548
         UIUtil.playSoundNotification('userLeft');
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
 }
205
 }
206
 
206
 
207
 function changeVideo(isVisible) {
207
 function changeVideo(isVisible) {
208
+
209
+    if (!currentSmallVideo) {
210
+        console.error("Unable to change large video - no 'currentSmallVideo'");
211
+        return;
212
+    }
213
+
208
     updateActiveSpeakerAvatarSrc();
214
     updateActiveSpeakerAvatarSrc();
209
 
215
 
210
     APP.RTC.setVideoSrc($('#largeVideo')[0], currentSmallVideo.getSrc());
216
     APP.RTC.setVideoSrc($('#largeVideo')[0], currentSmallVideo.getSrc());

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

119
             var newResourceJid;
119
             var newResourceJid;
120
             // We'll show user's avatar if he is the dominant speaker or if
120
             // We'll show user's avatar if he is the dominant speaker or if
121
             // his video thumbnail is pinned
121
             // his video thumbnail is pinned
122
-            if (resourceJid === focusedVideoResourceJid ||
122
+            if (remoteVideos[resourceJid] &&
123
+                resourceJid === focusedVideoResourceJid ||
123
                 resourceJid === currentDominantSpeaker) {
124
                 resourceJid === currentDominantSpeaker) {
124
                 newResourceJid = resourceJid;
125
                 newResourceJid = resourceJid;
125
             } else {
126
             } else {
137
         var videoElem = RTC.getVideoElementName();
138
         var videoElem = RTC.getVideoElementName();
138
         var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last>' + videoElem);
139
         var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last>' + videoElem);
139
         if (pick.length && APP.RTC.getVideoSrc(pick[0])) {
140
         if (pick.length && APP.RTC.getVideoSrc(pick[0])) {
140
-            return VideoLayout.getPeerContainerResourceJid(pick[0].parentNode);
141
+            jid = VideoLayout.getPeerContainerResourceJid(pick[0].parentNode);
141
         } else {
142
         } else {
142
             console.info("Last visible video no longer exists");
143
             console.info("Last visible video no longer exists");
143
             pick = $('#remoteVideos>span[id!="mixedstream"]>' + videoElem);
144
             pick = $('#remoteVideos>span[id!="mixedstream"]>' + videoElem);
144
             if (pick.length && APP.RTC.getVideoSrc(pick[0])) {
145
             if (pick.length && APP.RTC.getVideoSrc(pick[0])) {
145
-                return VideoLayout.getPeerContainerResourceJid(pick[0].parentNode);
146
+                jid = VideoLayout.getPeerContainerResourceJid(pick[0].parentNode);
146
             } else {
147
             } else {
147
                 // Try local video
148
                 // Try local video
148
                 console.info("Fallback to local video...");
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
     my.onRemoteStreamAdded = function (stream) {
157
     my.onRemoteStreamAdded = function (stream) {
784
             remoteVideos[resourceJid].updateStatsIndicator(percent, object);
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
      * Hides the connection indicator
791
      * Hides the connection indicator
797
      * @param jid
792
      * @param jid
819
             console.info("Focused video owner has left the conference");
814
             console.info("Focused video owner has left the conference");
820
             focusedVideoResourceJid = null;
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
     my.onVideoTypeChanged = function (jid) {
836
     my.onVideoTypeChanged = function (jid) {

Loading…
取消
儲存