|
@@ -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
|
+
|