Explorar el Código

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

master
Hristo Terezov hace 5 años
padre
commit
809ac42e4c

+ 7
- 1
modules/UI/videolayout/VideoContainer.js Ver fichero

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

+ 45
- 10
react/features/large-video/components/LargeVideoBackground.web.js Ver fichero

@@ -2,6 +2,9 @@
2 2
 
3 3
 import React, { Component } from 'react';
4 4
 
5
+import { connect } from '../../base/redux';
6
+import { shouldDisplayTileView } from '../../video-layout';
7
+
5 8
 /**
6 9
  * Constants to describe the dimensions of the video. Landscape videos
7 10
  * are wider than they are taller and portrait videos are taller than they
@@ -21,6 +24,14 @@ export const ORIENTATION = {
21 24
  */
22 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 36
      * Additional CSS class names to add to the root of the component.
26 37
      */
@@ -83,7 +94,9 @@ export class LargeVideoBackground extends Component<Props> {
83 94
      * @returns {void}
84 95
      */
85 96
     componentDidMount() {
86
-        if (this.props.videoElement && !this.props.hidden) {
97
+        const { _shouldDisplayTileView, hidden, videoElement } = this.props;
98
+
99
+        if (videoElement && !hidden && !_shouldDisplayTileView) {
87 100
             this._updateCanvas();
88 101
             this._setUpdateCanvasInterval();
89 102
         }
@@ -95,15 +108,18 @@ export class LargeVideoBackground extends Component<Props> {
95 108
      * @inheritdoc
96 109
      */
97 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,3 +232,22 @@ export class LargeVideoBackground extends Component<Props> {
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
+

Loading…
Cancelar
Guardar