浏览代码

fix(largeVideo-bg):render canvas only when visible

master
Hristo Terezov 5 年前
父节点
当前提交
809ac42e4c

+ 7
- 1
modules/UI/videolayout/VideoContainer.js 查看文件

206
          */
206
          */
207
         this._hideBackground = true;
207
         this._hideBackground = true;
208
 
208
 
209
+        this._isHidden = false;
210
+
209
         /**
211
         /**
210
          * Flag indicates whether or not the avatar is currently displayed.
212
          * Flag indicates whether or not the avatar is currently displayed.
211
          * @type {boolean}
213
          * @type {boolean}
561
                 FADE_DURATION_MS,
563
                 FADE_DURATION_MS,
562
                 1,
564
                 1,
563
                 () => {
565
                 () => {
566
+                    this._isHidden = false;
567
+                    this._updateBackground();
564
                     resolve();
568
                     resolve();
565
                 }
569
                 }
566
             );
570
             );
578
         return new Promise(resolve => {
582
         return new Promise(resolve => {
579
             this.$wrapperParent.fadeTo(FADE_DURATION_MS, 0, () => {
583
             this.$wrapperParent.fadeTo(FADE_DURATION_MS, 0, () => {
580
                 this.$wrapperParent.css('visibility', 'hidden');
584
                 this.$wrapperParent.css('visibility', 'hidden');
585
+                this._isHidden = true;
586
+                this._updateBackground();
581
                 resolve();
587
                 resolve();
582
             });
588
             });
583
         });
589
         });
635
 
641
 
636
         ReactDOM.render(
642
         ReactDOM.render(
637
             <LargeVideoBackground
643
             <LargeVideoBackground
638
-                hidden = { this._hideBackground }
644
+                hidden = { this._hideBackground || this._isHidden }
639
                 mirror = {
645
                 mirror = {
640
                     this.stream
646
                     this.stream
641
                     && this.stream.isLocal()
647
                     && this.stream.isLocal()

+ 45
- 10
react/features/large-video/components/LargeVideoBackground.web.js 查看文件

2
 
2
 
3
 import React, { Component } from 'react';
3
 import React, { Component } from 'react';
4
 
4
 
5
+import { connect } from '../../base/redux';
6
+import { shouldDisplayTileView } from '../../video-layout';
7
+
5
 /**
8
 /**
6
  * Constants to describe the dimensions of the video. Landscape videos
9
  * Constants to describe the dimensions of the video. Landscape videos
7
  * are wider than they are taller and portrait videos are taller than they
10
  * are wider than they are taller and portrait videos are taller than they
21
  */
24
  */
22
 type Props = {
25
 type Props = {
23
 
26
 
27
+   /**
28
+     * Whether or not the layout should change to support tile view mode.
29
+     *
30
+     * @protected
31
+     * @type {boolean}
32
+     */
33
+    _shouldDisplayTileView: boolean,
34
+
24
     /**
35
     /**
25
      * Additional CSS class names to add to the root of the component.
36
      * Additional CSS class names to add to the root of the component.
26
      */
37
      */
83
      * @returns {void}
94
      * @returns {void}
84
      */
95
      */
85
     componentDidMount() {
96
     componentDidMount() {
86
-        if (this.props.videoElement && !this.props.hidden) {
97
+        const { _shouldDisplayTileView, hidden, videoElement } = this.props;
98
+
99
+        if (videoElement && !hidden && !_shouldDisplayTileView) {
87
             this._updateCanvas();
100
             this._updateCanvas();
88
             this._setUpdateCanvasInterval();
101
             this._setUpdateCanvasInterval();
89
         }
102
         }
95
      * @inheritdoc
108
      * @inheritdoc
96
      */
109
      */
97
     componentDidUpdate(prevProps: Props) {
110
     componentDidUpdate(prevProps: Props) {
98
-        if (prevProps.hidden && !this.props.hidden) {
99
-            this._clearCanvas();
100
-            this._setUpdateCanvasInterval();
101
-        }
102
-
103
-        if ((!prevProps.hidden && this.props.hidden)
104
-            || !this.props.videoElement) {
105
-            this._clearCanvas();
106
-            this._clearUpdateCanvasInterval();
111
+        const wasCanvasUpdating = !prevProps.hidden && !prevProps._shouldDisplayTileView && prevProps.videoElement;
112
+        const shouldCanvasUpdating
113
+            = !this.props.hidden && !this.props._shouldDisplayTileView && this.props.videoElement;
114
+
115
+        if (wasCanvasUpdating !== shouldCanvasUpdating) {
116
+            if (shouldCanvasUpdating) {
117
+                this._clearCanvas();
118
+                this._setUpdateCanvasInterval();
119
+            } else {
120
+                this._clearCanvas();
121
+                this._clearUpdateCanvasInterval();
122
+            }
107
         }
123
         }
108
     }
124
     }
109
 
125
 
216
         }
232
         }
217
     }
233
     }
218
 }
234
 }
235
+
236
+/**
237
+ * Maps (parts of) the Redux state to the associated LargeVideoBackground props.
238
+ *
239
+ * @param {Object} state - The Redux state.
240
+ * @private
241
+ * @returns {{
242
+ *     _shouldDisplayTileView: boolean
243
+ * }}
244
+ */
245
+function _mapStateToProps(state) {
246
+    return {
247
+        _shouldDisplayTileView: shouldDisplayTileView(state)
248
+    };
249
+}
250
+
251
+
252
+export default connect(_mapStateToProps)(LargeVideoBackground);
253
+

正在加载...
取消
保存