瀏覽代碼

Fixes a bug with prematurely removed remote videos on firefox.

master
Boris Grozev 10 年之前
父節點
當前提交
0bbae86f68
共有 2 個檔案被更改,包括 26 行新增24 行删除
  1. 3
    13
      modules/UI/videolayout/RemoteVideo.js
  2. 23
    11
      modules/UI/videolayout/VideoLayout.js

+ 3
- 13
modules/UI/videolayout/RemoteVideo.js 查看文件

@@ -168,6 +168,9 @@ RemoteVideo.prototype.removeRemoteStreamElement =
168 168
 RemoteVideo.prototype.remove = function () {
169 169
     console.log("Remove thumbnail", this.peerJid);
170 170
     this.removeConnectionIndicator();
171
+    // Make sure that the large video is updated if are removing its
172
+    // corresponding small video.
173
+    this.VideoLayout.updateRemovedVideo(this.getResourceJid());
171 174
     // Remove whole container
172 175
     if (this.container.parentNode)
173 176
         this.container.parentNode.removeChild(this.container);
@@ -233,19 +236,6 @@ RemoteVideo.prototype.addRemoteStreamElement = function (stream) {
233 236
 
234 237
     };
235 238
 
236
-    /**
237
-     * FF is missing onended event for remote streams. The problem we are fixing
238
-     * here is when the last participant leaves the room the video element is
239
-     * not updated. So the avatar or last video frame will stay, the fix updates
240
-     * the video elem and switches to local video the same as behavior in other
241
-     * browsers.
242
-     */
243
-    if (RTCBrowserType.isFirefox()) {
244
-        APP.xmpp.addListener(XMPPEvents.MUC_MEMBER_LEFT, function (jid) {
245
-            self.removeRemoteStreamElement(stream, isVideo, newElementId);
246
-        });
247
-    }
248
-
249 239
     // Add click handler.
250 240
     var onClickHandler = function (event) {
251 241
 

+ 23
- 11
modules/UI/videolayout/VideoLayout.js 查看文件

@@ -126,12 +126,11 @@ var VideoLayout = (function (my) {
126 126
     /**
127 127
      * Checks if removed video is currently displayed and tries to display
128 128
      * another one instead.
129
-     * @param removedVideoSrc src stream identifier of the video.
130 129
      */
131 130
     my.updateRemovedVideo = function(resourceJid) {
131
+        var newResourceJid;
132 132
 
133 133
         if (resourceJid === LargeVideo.getResourceJid()) {
134
-            var newResourceJid;
135 134
             // We'll show user's avatar if he is the dominant speaker or if
136 135
             // his video thumbnail is pinned
137 136
             if (remoteVideos[resourceJid] &&
@@ -153,18 +152,32 @@ var VideoLayout = (function (my) {
153 152
         var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last');
154 153
         if (pick.length) {
155 154
             jid = VideoLayout.getPeerContainerResourceJid(pick[0]);
156
-        } else {
155
+            if (!remoteVideos[jid]) {
156
+                // The RemoteVideo was removed (but the DOM elements may still
157
+                // exist).
158
+                jid = null;
159
+            }
160
+        }
161
+
162
+        if (!jid) {
157 163
             console.info("Last visible video no longer exists");
158 164
             pick = $('#remoteVideos>span[id!="mixedstream"]');
159 165
             if (pick.length) {
160 166
                 jid = VideoLayout.getPeerContainerResourceJid(pick[0]);
161
-            }
162
-            if (!jid) {
163
-                // Go with local video
164
-                console.info("Fallback to local video...");
165
-                jid = APP.xmpp.myResource();
167
+                if (!remoteVideos[jid]) {
168
+                    // The RemoteVideo was removed (but the DOM elements may
169
+                    // still exist).
170
+                    jid = null;
171
+                }
166 172
             }
167 173
         }
174
+
175
+        if (!jid) {
176
+            // Go with local video
177
+            console.info("Fallback to local video...");
178
+            jid = APP.xmpp.myResource();
179
+        }
180
+
168 181
         console.info("electLastVisibleVideo: " + jid);
169 182
         return jid;
170 183
     };
@@ -830,8 +843,7 @@ var VideoLayout = (function (my) {
830 843
             focusedVideoResourceJid = null;
831 844
         }
832 845
 
833
-        if (currentDominantSpeaker === resourceJid)
834
-        {
846
+        if (currentDominantSpeaker === resourceJid) {
835 847
             console.info("Dominant speaker has left the conference");
836 848
             currentDominantSpeaker = null;
837 849
         }
@@ -840,8 +852,8 @@ var VideoLayout = (function (my) {
840 852
         if (remoteVideo) {
841 853
             // Remove remote video
842 854
             console.info("Removing remote video: " + resourceJid);
843
-            remoteVideo.remove();
844 855
             delete remoteVideos[resourceJid];
856
+            remoteVideo.remove();
845 857
         } else {
846 858
             console.warn("No remote video for " + resourceJid);
847 859
         }

Loading…
取消
儲存