@gravity-ui/page-constructor 4.5.0 → 4.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -37,6 +37,8 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
37
37
|
const [started, setStarted] = (0, react_1.useState)(autoPlay);
|
|
38
38
|
const [paused, setPaused] = (0, react_1.useState)(false);
|
|
39
39
|
const [ended, setEnded] = (0, react_1.useState)(false);
|
|
40
|
+
const [isMounted, setIsMounted] = react_1.default.useState(false);
|
|
41
|
+
(0, hooks_1.useMount)(() => setIsMounted(true));
|
|
40
42
|
const videoSrc = (0, react_1.useMemo)(() => (0, utils_2.checkYoutubeVideos)(src), [src]);
|
|
41
43
|
const eventsArray = (0, react_1.useMemo)(() => {
|
|
42
44
|
if (analyticsEvents) {
|
|
@@ -195,9 +197,9 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
|
|
|
195
197
|
},
|
|
196
198
|
}, elapsedTimePercent: elapsedTimePercent }));
|
|
197
199
|
}, [controls, isPlaying, customBarControlsClassName, changeMute]);
|
|
198
|
-
return (react_1.default.createElement("div", { className: b({ wrapper: !currentHeight }, className), ref: ref, onClick: handleClick },
|
|
200
|
+
return (react_1.default.createElement("div", { className: b({ wrapper: !currentHeight }, className), ref: ref, onClick: handleClick }, isMounted ? (react_1.default.createElement(react_1.Fragment, null,
|
|
199
201
|
react_1.default.createElement(react_player_1.default, { className: b('player'), url: videoSrc, muted: muted, controls: controls === models_1.MediaVideoControlsType.Default, height: currentHeight || '100%', width: width || '100%', light: previewImgUrl, playing: isPlaying, playIcon: playIcon, progressInterval: FPS, onClickPreview: handleClickPreview, onStart: onStart, onReady: setPlayerRef, onPlay: onPlay, onPause: onPause, onProgress: onProgress, onEnded: onEnded, "aria-label": ariaLabel }),
|
|
200
|
-
renderCustomBarControls(muted, playedPercent)));
|
|
202
|
+
renderCustomBarControls(muted, playedPercent))) : null));
|
|
201
203
|
});
|
|
202
204
|
function getHeight(width) {
|
|
203
205
|
return (width / 16) * 9;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React, { useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState, } from 'react';
|
|
1
|
+
import React, { Fragment, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState, } from 'react';
|
|
2
2
|
import { Icon } from '@gravity-ui/uikit';
|
|
3
3
|
import _ from 'lodash';
|
|
4
4
|
import ReactPlayer from 'react-player';
|
|
5
5
|
import { MetrikaContext } from '../../context/metrikaContext';
|
|
6
6
|
import { MobileContext } from '../../context/mobileContext';
|
|
7
7
|
import { VideoContext } from '../../context/videoContext';
|
|
8
|
-
import { useAnalytics } from '../../hooks';
|
|
8
|
+
import { useAnalytics, useMount } from '../../hooks';
|
|
9
9
|
import { PlayVideo } from '../../icons';
|
|
10
10
|
import { DefaultEventNames, MediaVideoControlsType, PlayButtonThemes, PlayButtonType, PredefinedEventTypes, } from '../../models';
|
|
11
11
|
import { block } from '../../utils';
|
|
@@ -34,6 +34,8 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
34
34
|
const [started, setStarted] = useState(autoPlay);
|
|
35
35
|
const [paused, setPaused] = useState(false);
|
|
36
36
|
const [ended, setEnded] = useState(false);
|
|
37
|
+
const [isMounted, setIsMounted] = React.useState(false);
|
|
38
|
+
useMount(() => setIsMounted(true));
|
|
37
39
|
const videoSrc = useMemo(() => checkYoutubeVideos(src), [src]);
|
|
38
40
|
const eventsArray = useMemo(() => {
|
|
39
41
|
if (analyticsEvents) {
|
|
@@ -192,9 +194,9 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
|
|
|
192
194
|
},
|
|
193
195
|
}, elapsedTimePercent: elapsedTimePercent }));
|
|
194
196
|
}, [controls, isPlaying, customBarControlsClassName, changeMute]);
|
|
195
|
-
return (React.createElement("div", { className: b({ wrapper: !currentHeight }, className), ref: ref, onClick: handleClick },
|
|
197
|
+
return (React.createElement("div", { className: b({ wrapper: !currentHeight }, className), ref: ref, onClick: handleClick }, isMounted ? (React.createElement(Fragment, null,
|
|
196
198
|
React.createElement(ReactPlayer, { className: b('player'), url: videoSrc, muted: muted, controls: controls === MediaVideoControlsType.Default, height: currentHeight || '100%', width: width || '100%', light: previewImgUrl, playing: isPlaying, playIcon: playIcon, progressInterval: FPS, onClickPreview: handleClickPreview, onStart: onStart, onReady: setPlayerRef, onPlay: onPlay, onPause: onPause, onProgress: onProgress, onEnded: onEnded, "aria-label": ariaLabel }),
|
|
197
|
-
renderCustomBarControls(muted, playedPercent)));
|
|
199
|
+
renderCustomBarControls(muted, playedPercent))) : null));
|
|
198
200
|
});
|
|
199
201
|
function getHeight(width) {
|
|
200
202
|
return (width / 16) * 9;
|