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 ,
@@ -104,6 +105,9 @@ export const ReactPlayerBlock = React.forwardRef<ReactPlayerBlockHandler, ReactP
104105 const [ started , setStarted ] = useState ( autoPlay ) ;
105106 const [ paused , setPaused ] = useState < boolean > ( false ) ;
106107 const [ ended , setEnded ] = useState < boolean > ( false ) ;
108+ const [ isMounted , setIsMounted ] = React . useState ( false ) ;
109+
110+ useMount ( ( ) => setIsMounted ( true ) ) ;
107111
108112 const videoSrc = useMemo ( ( ) => checkYoutubeVideos ( src ) , [ src ] ) ;
109113
@@ -337,27 +341,31 @@ export const ReactPlayerBlock = React.forwardRef<ReactPlayerBlockHandler, ReactP
337341 ref = { ref }
338342 onClick = { handleClick }
339343 >
340- < ReactPlayer
341- className = { b ( 'player' ) }
342- url = { videoSrc }
343- muted = { muted }
344- controls = { controls === MediaVideoControlsType . Default }
345- height = { currentHeight || '100%' }
346- width = { width || '100%' }
347- light = { previewImgUrl }
348- playing = { isPlaying }
349- playIcon = { playIcon }
350- progressInterval = { FPS }
351- onClickPreview = { handleClickPreview }
352- onStart = { onStart }
353- onReady = { setPlayerRef }
354- onPlay = { onPlay }
355- onPause = { onPause }
356- onProgress = { onProgress }
357- onEnded = { onEnded }
358- aria-label = { ariaLabel }
359- />
360- { renderCustomBarControls ( muted , playedPercent ) }
344+ { isMounted ? (
345+ < Fragment >
346+ < ReactPlayer
347+ className = { b ( 'player' ) }
348+ url = { videoSrc }
349+ muted = { muted }
350+ controls = { controls === MediaVideoControlsType . Default }
351+ height = { currentHeight || '100%' }
352+ width = { width || '100%' }
353+ light = { previewImgUrl }
354+ playing = { isPlaying }
355+ playIcon = { playIcon }
356+ progressInterval = { FPS }
357+ onClickPreview = { handleClickPreview }
358+ onStart = { onStart }
359+ onReady = { setPlayerRef }
360+ onPlay = { onPlay }
361+ onPause = { onPause }
362+ onProgress = { onProgress }
363+ onEnded = { onEnded }
364+ aria-label = { ariaLabel }
365+ />
366+ { renderCustomBarControls ( muted , playedPercent ) }
367+ </ Fragment >
368+ ) : null }
361369 </ div >
362370 ) ;
363371 } ,
0 commit comments