浏览代码

Fixes local video flickering when locally muted. Rearranges some of the large video avatar related code.

j8
yanas 9 年前
父节点
当前提交
3fe0487df7
共有 2 个文件被更改,包括 40 次插入22 次删除
  1. 39
    16
      modules/UI/videolayout/LargeVideo.js
  2. 1
    6
      modules/UI/videolayout/VideoLayout.js

+ 39
- 16
modules/UI/videolayout/LargeVideo.js 查看文件

@@ -5,6 +5,7 @@ import UIUtil from "../util/UIUtil";
5 5
 import UIEvents from "../../../service/UI/UIEvents";
6 6
 import LargeContainer from './LargeContainer';
7 7
 import BottomToolbar from '../toolbars/BottomToolbar';
8
+import Avatar from "../avatar/Avatar";
8 9
 
9 10
 const RTCBrowserType = require("../../RTC/RTCBrowserType");
10 11
 
@@ -184,23 +185,38 @@ class VideoContainer extends LargeContainer {
184 185
     getVideoSize (containerWidth, containerHeight) {
185 186
         let { width, height } = this.getStreamSize();
186 187
         if (this.stream && this.isScreenSharing()) {
187
-            return getDesktopVideoSize(width, height, containerWidth, containerHeight);
188
+            return getDesktopVideoSize( width,
189
+                                        height,
190
+                                        containerWidth,
191
+                                        containerHeight);
188 192
         } else {
189
-            return getCameraVideoSize(width, height, containerWidth, containerHeight);
193
+            return getCameraVideoSize(  width,
194
+                                        height,
195
+                                        containerWidth,
196
+                                        containerHeight);
190 197
         }
191 198
     }
192 199
 
193 200
     getVideoPosition (width, height, containerWidth, containerHeight) {
194 201
         if (this.stream && this.isScreenSharing()) {
195
-            return getDesktopVideoPosition(width, height, containerWidth, containerHeight);
202
+            return getDesktopVideoPosition( width,
203
+                                            height,
204
+                                            containerWidth,
205
+                                            containerHeight);
196 206
         } else {
197
-            return getCameraVideoPosition(width, height, containerWidth, containerHeight);
207
+            return getCameraVideoPosition(  width,
208
+                                            height,
209
+                                            containerWidth,
210
+                                            containerHeight);
198 211
         }
199 212
     }
200 213
 
201 214
     resize (containerWidth, containerHeight, animate = false) {
202
-        let { width, height } = this.getVideoSize(containerWidth, containerHeight);
203
-        let { horizontalIndent, verticalIndent } = this.getVideoPosition(width, height, containerWidth, containerHeight);
215
+        let { width, height }
216
+            = this.getVideoSize(containerWidth, containerHeight);
217
+        let { horizontalIndent, verticalIndent }
218
+            = this.getVideoPosition(width, height,
219
+                                    containerWidth, containerHeight);
204 220
 
205 221
         // update avatar position
206 222
         let top = containerHeight / 2 - avatarSize / 4 * 3;
@@ -239,9 +255,6 @@ class VideoContainer extends LargeContainer {
239 255
     }
240 256
 
241 257
     showAvatar (show) {
242
-        // if we are showing the avatar, this means there is no video on large
243
-        // so let's hide its video wrapper
244
-        show ? this.hide() : this.show();
245 258
         this.$avatar.css("visibility", show ? "visible" : "hidden");
246 259
     }
247 260
 
@@ -253,7 +266,7 @@ class VideoContainer extends LargeContainer {
253 266
 
254 267
     show () {
255 268
         let $wrapper = this.$wrapper;
256
-        return new Promise(resolve => {
269
+        return new Promise(function(resolve) {
257 270
             $wrapper.fadeIn(300, function () {
258 271
                 $wrapper.css({visibility: 'visible'});
259 272
                 $('.watermark').css({visibility: 'visible'});
@@ -263,11 +276,10 @@ class VideoContainer extends LargeContainer {
263 276
     }
264 277
 
265 278
     hide () {
266
-        this.showAvatar(false);
267 279
 
268 280
         let $wrapper = this.$wrapper;
269 281
 
270
-        return new Promise(resolve => {
282
+        return new Promise(function(resolve) {
271 283
             $wrapper.fadeOut(300, function () {
272 284
                 $wrapper.css({visibility: 'hidden'});
273 285
                 $('.watermark').css({visibility: 'hidden'});
@@ -344,16 +356,26 @@ export default class LargeVideoManager {
344 356
         return this.videoContainer.id;
345 357
     }
346 358
 
347
-    updateLargeVideo (stream, videoType, largeVideoUpdatedCallBack) {
348
-        let id = getStreamId(stream);
359
+    updateLargeVideo (smallVideo, videoType, largeVideoUpdatedCallBack) {
360
+        let id = getStreamId(smallVideo.stream);
349 361
 
350 362
         let container = this.getContainer(this.state);
351 363
 
352 364
         container.hide().then(() => {
353 365
             console.info("hover in %s", id);
354 366
             this.state = VideoContainerType;
355
-            this.videoContainer.setStream(stream, videoType);
356
-            this.videoContainer.show();
367
+            this.videoContainer.setStream(smallVideo.stream, videoType);
368
+
369
+            // change the avatar url on large
370
+            this.updateAvatar(Avatar.getAvatarUrl(smallVideo.id));
371
+
372
+            var isVideoMuted = smallVideo.stream.isMuted()
373
+            // show the avatar on large if needed
374
+            this.videoContainer.showAvatar(isVideoMuted);
375
+
376
+            if (!isVideoMuted)
377
+                this.videoContainer.show();
378
+
357 379
             largeVideoUpdatedCallBack();
358 380
         });
359 381
     }
@@ -399,6 +421,7 @@ export default class LargeVideoManager {
399 421
     }
400 422
 
401 423
     showAvatar (show) {
424
+        show ? this.videoContainer.hide() : this.videoContainer.show();
402 425
         this.videoContainer.showAvatar(show);
403 426
     }
404 427
 

+ 1
- 6
modules/UI/videolayout/VideoLayout.js 查看文件

@@ -990,18 +990,13 @@ var VideoLayout = {
990 990
 
991 991
             let videoType = this.getRemoteVideoType(id);
992 992
             largeVideo.updateLargeVideo(
993
-                smallVideo.stream,
993
+                smallVideo,
994 994
                 videoType,
995 995
                 // LargeVideoUpdatedCallBack
996 996
                 function() {
997 997
                     // update current small video and the old one
998 998
                     smallVideo.updateView();
999 999
                     oldSmallVideo && oldSmallVideo.updateView();
1000
-
1001
-                    // change the avatar url on large
1002
-                    largeVideo.updateAvatar(Avatar.getAvatarUrl(smallVideo.id));
1003
-                    // show the avatar on large if needed
1004
-                    largeVideo.showAvatar(smallVideo.stream.isMuted());
1005 1000
                 });
1006 1001
 
1007 1002
         } else if (currentId) {

正在加载...
取消
保存