11import React , {
2+ Fragment ,
23 useCallback ,
34 useContext ,
45 useEffect ,
@@ -15,7 +16,7 @@ import ReactPlayer from 'react-player';
1516import { MetrikaContext } from '../../context/metrikaContext' ;
1617import { MobileContext } from '../../context/mobileContext' ;
1718import { VideoContext } from '../../context/videoContext' ;
18- import { useAnalytics } from '../../hooks' ;
19+ import { useAnalytics , useMount } from '../../hooks' ;
1920import { PlayVideo } from '../../icons' ;
2021import {
2122 AnalyticsEvent ,
@@ -102,6 +103,9 @@ export const ReactPlayerBlock = React.forwardRef<ReactPlayerBlockHandler, ReactP
102103 const [ started , setStarted ] = useState ( autoPlay ) ;
103104 const [ paused , setPaused ] = useState < boolean > ( false ) ;
104105 const [ ended , setEnded ] = useState < boolean > ( false ) ;
106+ const [ isMounted , setIsMounted ] = React . useState ( false ) ;
107+
108+ useMount ( ( ) => setIsMounted ( true ) ) ;
105109
106110 const videoSrc = useMemo ( ( ) => checkYoutubeVideos ( src ) , [ src ] ) ;
107111
@@ -332,26 +336,30 @@ export const ReactPlayerBlock = React.forwardRef<ReactPlayerBlockHandler, ReactP
332336 ref = { ref }
333337 onClick = { handleClick }
334338 >
335- < ReactPlayer
336- className = { b ( 'player' ) }
337- url = { videoSrc }
338- muted = { muted }
339- controls = { controls === MediaVideoControlsType . Default }
340- height = { currentHeight || '100%' }
341- width = { width || '100%' }
342- light = { previewImgUrl }
343- playing = { isPlaying }
344- playIcon = { playIcon }
345- progressInterval = { FPS }
346- onClickPreview = { handleClickPreview }
347- onStart = { onStart }
348- onReady = { setPlayerRef }
349- onPlay = { onPlay }
350- onPause = { onPause }
351- onProgress = { onProgress }
352- onEnded = { onEnded }
353- />
354- { renderCustomBarControls ( muted , playedPercent ) }
339+ { isMounted ? (
340+ < Fragment >
341+ < ReactPlayer
342+ className = { b ( 'player' ) }
343+ url = { videoSrc }
344+ muted = { muted }
345+ controls = { controls === MediaVideoControlsType . Default }
346+ height = { currentHeight || '100%' }
347+ width = { width || '100%' }
348+ light = { previewImgUrl }
349+ playing = { isPlaying }
350+ playIcon = { playIcon }
351+ progressInterval = { FPS }
352+ onClickPreview = { handleClickPreview }
353+ onStart = { onStart }
354+ onReady = { setPlayerRef }
355+ onPlay = { onPlay }
356+ onPause = { onPause }
357+ onProgress = { onProgress }
358+ onEnded = { onEnded }
359+ />
360+ { renderCustomBarControls ( muted , playedPercent ) }
361+ </ Fragment >
362+ ) : null }
355363 </ div >
356364 ) ;
357365 } ,
0 commit comments