Browse Source

Fixes a bug with prematurely removed remote videos on firefox.

master
Boris Grozev 10 years ago
parent
commit
0bbae86f68
2 changed files with 26 additions and 24 deletions
  1. 3
    13
      modules/UI/videolayout/RemoteVideo.js
  2. 23
    11
      modules/UI/videolayout/VideoLayout.js

+ 3
- 13
modules/UI/videolayout/RemoteVideo.js View File

168
 RemoteVideo.prototype.remove = function () {
168
 RemoteVideo.prototype.remove = function () {
169
     console.log("Remove thumbnail", this.peerJid);
169
     console.log("Remove thumbnail", this.peerJid);
170
     this.removeConnectionIndicator();
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
     // Remove whole container
174
     // Remove whole container
172
     if (this.container.parentNode)
175
     if (this.container.parentNode)
173
         this.container.parentNode.removeChild(this.container);
176
         this.container.parentNode.removeChild(this.container);
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
     // Add click handler.
239
     // Add click handler.
250
     var onClickHandler = function (event) {
240
     var onClickHandler = function (event) {
251
 
241
 

+ 23
- 11
modules/UI/videolayout/VideoLayout.js View File

126
     /**
126
     /**
127
      * Checks if removed video is currently displayed and tries to display
127
      * Checks if removed video is currently displayed and tries to display
128
      * another one instead.
128
      * another one instead.
129
-     * @param removedVideoSrc src stream identifier of the video.
130
      */
129
      */
131
     my.updateRemovedVideo = function(resourceJid) {
130
     my.updateRemovedVideo = function(resourceJid) {
131
+        var newResourceJid;
132
 
132
 
133
         if (resourceJid === LargeVideo.getResourceJid()) {
133
         if (resourceJid === LargeVideo.getResourceJid()) {
134
-            var newResourceJid;
135
             // We'll show user's avatar if he is the dominant speaker or if
134
             // We'll show user's avatar if he is the dominant speaker or if
136
             // his video thumbnail is pinned
135
             // his video thumbnail is pinned
137
             if (remoteVideos[resourceJid] &&
136
             if (remoteVideos[resourceJid] &&
153
         var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last');
152
         var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last');
154
         if (pick.length) {
153
         if (pick.length) {
155
             jid = VideoLayout.getPeerContainerResourceJid(pick[0]);
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
             console.info("Last visible video no longer exists");
163
             console.info("Last visible video no longer exists");
158
             pick = $('#remoteVideos>span[id!="mixedstream"]');
164
             pick = $('#remoteVideos>span[id!="mixedstream"]');
159
             if (pick.length) {
165
             if (pick.length) {
160
                 jid = VideoLayout.getPeerContainerResourceJid(pick[0]);
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
         console.info("electLastVisibleVideo: " + jid);
181
         console.info("electLastVisibleVideo: " + jid);
169
         return jid;
182
         return jid;
170
     };
183
     };
830
             focusedVideoResourceJid = null;
843
             focusedVideoResourceJid = null;
831
         }
844
         }
832
 
845
 
833
-        if (currentDominantSpeaker === resourceJid)
834
-        {
846
+        if (currentDominantSpeaker === resourceJid) {
835
             console.info("Dominant speaker has left the conference");
847
             console.info("Dominant speaker has left the conference");
836
             currentDominantSpeaker = null;
848
             currentDominantSpeaker = null;
837
         }
849
         }
840
         if (remoteVideo) {
852
         if (remoteVideo) {
841
             // Remove remote video
853
             // Remove remote video
842
             console.info("Removing remote video: " + resourceJid);
854
             console.info("Removing remote video: " + resourceJid);
843
-            remoteVideo.remove();
844
             delete remoteVideos[resourceJid];
855
             delete remoteVideos[resourceJid];
856
+            remoteVideo.remove();
845
         } else {
857
         } else {
846
             console.warn("No remote video for " + resourceJid);
858
             console.warn("No remote video for " + resourceJid);
847
         }
859
         }

Loading…
Cancel
Save