Переглянути джерело

Merge pull request #545 from damencho/fix-video-switching-on-hide-container

Fix video switching on hide container
master
yanas 9 роки тому
джерело
коміт
4ffafbe9a8

+ 1
- 1
modules/UI/shared_video/SharedVideo.js Переглянути файл

@@ -392,7 +392,7 @@ SharedVideoThumb.prototype.remove = function () {
392 392
 
393 393
     // Make sure that the large video is updated if are removing its
394 394
     // corresponding small video.
395
-    this.VideoLayout.updateRemovedVideo(this.id);
395
+    this.VideoLayout.updateAfterThumbRemoved(this.id);
396 396
 
397 397
     // Remove whole container
398 398
     if (this.container.parentNode) {

+ 4
- 1
modules/UI/videolayout/LocalVideo.js Переглянути файл

@@ -191,7 +191,10 @@ LocalVideo.prototype.changeVideo = function (stream) {
191 191
 
192 192
     let endedHandler = () => {
193 193
         localVideoContainer.removeChild(localVideo);
194
-        this.VideoLayout.updateRemovedVideo(this.id);
194
+        // when removing only the video element and we are on stage
195
+        // update the stage
196
+        if(this.VideoLayout.isCurrentlyOnLarge(this.id))
197
+            this.VideoLayout.updateLargeVideo(this.id);
195 198
         stream.off(TrackEvents.LOCAL_TRACK_STOPPED, endedHandler);
196 199
     };
197 200
     stream.on(TrackEvents.LOCAL_TRACK_STOPPED, endedHandler);

+ 5
- 3
modules/UI/videolayout/RemoteVideo.js Переглянути файл

@@ -156,8 +156,10 @@ RemoteVideo.prototype.removeRemoteStreamElement = function (stream) {
156 156
     console.info((isVideo ? "Video" : "Audio") +
157 157
                  " removed " + this.id, select);
158 158
 
159
-    if (isVideo)
160
-        this.VideoLayout.updateRemovedVideo(this.id);
159
+    // when removing only the video element and we are on stage
160
+    // update the stage
161
+    if (isVideo && this.VideoLayout.isCurrentlyOnLarge(this.id))
162
+        this.VideoLayout.updateLargeVideo(this.id);
161 163
 };
162 164
 
163 165
 /**
@@ -168,7 +170,7 @@ RemoteVideo.prototype.remove = function () {
168 170
     this.removeConnectionIndicator();
169 171
     // Make sure that the large video is updated if are removing its
170 172
     // corresponding small video.
171
-    this.VideoLayout.updateRemovedVideo(this.id);
173
+    this.VideoLayout.updateAfterThumbRemoved(this.id);
172 174
     // Remove whole container
173 175
     if (this.container.parentNode) {
174 176
         this.container.parentNode.removeChild(this.container);

+ 21
- 13
modules/UI/videolayout/VideoLayout.js Переглянути файл

@@ -199,23 +199,22 @@ var VideoLayout = {
199 199
     /**
200 200
      * Checks if removed video is currently displayed and tries to display
201 201
      * another one instead.
202
+     * Uses focusedID if any or dominantSpeakerID if any,
203
+     * otherwise elects new video, in this order.
202 204
      */
203
-    updateRemovedVideo (id) {
205
+    updateAfterThumbRemoved (id) {
204 206
         if (!this.isCurrentlyOnLarge(id)) {
205 207
             return;
206 208
         }
207 209
 
208 210
         let newId;
209 211
 
210
-        // We'll show user's avatar if he is the dominant speaker or if
211
-        // his video thumbnail is pinned
212
-        if (remoteVideos[id] && (id === pinnedId
213
-                                || id === currentDominantSpeaker)) {
214
-            newId = id;
215
-        } else {
216
-            // Otherwise select last visible video
212
+        if (pinnedId)
213
+            newId = pinnedId;
214
+        else if (currentDominantSpeaker)
215
+            newId = currentDominantSpeaker;
216
+        else // Otherwise select last visible video
217 217
             newId = this.electLastVisibleVideo();
218
-        }
219 218
 
220 219
         this.updateLargeVideo(newId);
221 220
     },
@@ -304,8 +303,7 @@ var VideoLayout = {
304 303
      */
305 304
     handleVideoThumbClicked (id) {
306 305
         if(pinnedId) {
307
-            var oldSmallVideo
308
-                    = VideoLayout.getSmallVideo(pinnedId);
306
+            var oldSmallVideo = VideoLayout.getSmallVideo(pinnedId);
309 307
             if (oldSmallVideo && !interfaceConfig.filmStripOnly)
310 308
                 oldSmallVideo.focus(false);
311 309
         }
@@ -978,8 +976,18 @@ var VideoLayout = {
978 976
             var oldSmallVideo = this.getSmallVideo(currentId);
979 977
         }
980 978
 
981
-        // if !show then use default type - large video
982
-        return largeVideo.showContainer(show ? type : VIDEO_CONTAINER_TYPE)
979
+        let containerTypeToShow = type;
980
+        // if we are hiding a container and there is focusedVideo
981
+        // (pinned remote video) use its video type,
982
+        // if not then use default type - large video
983
+        if (!show) {
984
+            if(pinnedId)
985
+                containerTypeToShow = this.getRemoteVideoType(pinnedId);
986
+            else
987
+                containerTypeToShow = VIDEO_CONTAINER_TYPE;
988
+        }
989
+
990
+        return largeVideo.showContainer(containerTypeToShow)
983 991
             .then(() => {
984 992
                 if(oldSmallVideo)
985 993
                     oldSmallVideo && oldSmallVideo.updateView();

Завантаження…
Відмінити
Зберегти