import { Fragment, memo } from 'react' import includes from 'lodash/includes' import isEmpty from 'lodash/isEmpty' import { isMobileDevice } from 'config' import { Loader } from 'features/Loader' import { VideoPlayer } from 'features/VideoPlayer' import { useMatchPageStore } from 'features/MatchPage/store' import { Name } from 'features/Name' import { FiltersPopup } from 'features/MatchSidePlaylists/components/FiltersPopup' import { WaterMark } from 'components/WaterMark' import { AccessTimer } from 'components/AccessTimer' import { PLAYER_ADS, PLAYER_MOBILE_ADS } from 'components/Ads/types' import { HeaderAds } from 'components/Ads' import { REWIND_SECONDS } from './config' import type { Props } from './hooks' import { useVideoPlayer } from './hooks' import { useAuthStore } from '../AuthStore' import { Controls } from './components/Controls' import RewindMobile from './components/RewindMobile' import { PlayerWrapper, CenterControls, PlayStop, LoaderWrapper, Backward, Forward, ControlsGradient, TeamsDetailsWrapper, EpisodeInfo, EpisodeInfoName, EpisodeInfoOrder, EpisodeInfoDivider, CloseButton, PlayerAdsWrapper, Canvas, } from './styled' const CanvasComponent = memo(Canvas) const tournamentsWithWatermark = { 316: 'Tunisia', 1136: 'Brasil', 1448: 'India', 5950: 'India', } /** * HLS плеер, применяется на лайв и завершенных матчах */ export const StreamPlayer = (props: Props) => { const { access, ads, episodeInfo, isOpenFiltersPopup, isPlayingEpisode, profile, } = useMatchPageStore() const { user } = useAuthStore() const { activeChapterIndex, allPlayedProgress, audioTracks, backToLive, buffering, canvasRef, centerControlsVisible, changeAudioTrack, chapters, currentPlayingOrder, duration, hideCenterControls, isFullscreen, isLive, isLiveTime, likeButtonRef, loadedProgress, mainControlsVisible, muted, onDuration, onError, onFullscreenClick, onLoadedProgress, onMouseEnter, onMouseLeave, onMouseMove, onPause, onPlay, onPlayedProgress, onPlayerClick, onPlaying, onProgressChange, onQualitySelect, onReady, onTouchEnd, onTouchStart, onVolumeChange, onVolumeClick, onWaiting, playedProgress, playing, ready, rewindBackward, rewindForward, seek, selectedAudioTrack, selectedQuality, setGenerateParticles, showCenterControls, stopPlayingEpisodes, togglePlaying, url, videoQualities, videoRef, volume, volumeInPercent, wrapperRef, } = useVideoPlayer(props) return ( {ads && ( (isMobileDevice ? position.id === PLAYER_MOBILE_ADS : includes(PLAYER_ADS, position.id)))} /> )} {isPlayingEpisode && ( {!isEmpty(episodeInfo) && ( {isMobileDevice ? ( {episodeInfo.playerOrTeamName} {episodeInfo.playerOrTeamName &&
} {episodeInfo.paramName}
) : `${episodeInfo.playerOrTeamName || ''}${episodeInfo.paramName && episodeInfo.playerOrTeamName ? ' - ' : ''}${episodeInfo.paramName || ''}`}
{currentPlayingOrder > 0 && ( {currentPlayingOrder} {episodeInfo.episodesCount} )}
)}
)} {isOpenFiltersPopup && } {user && (Boolean( tournamentsWithWatermark[profile?.tournament.id as keyof typeof tournamentsWithWatermark], ) || profile?.watermark) && playing && isLive && ( )} {isMobileDevice && isFullscreen && mainControlsVisible && profile && ( {` ${profile.team1.score}-${profile.team2.score} `} )} {ready && ( {isMobileDevice ? : {REWIND_SECONDS}} { togglePlaying() hideCenterControls() }} id='match_video_screen_start_stop' /> {isMobileDevice ? : {REWIND_SECONDS}} )} {!user && ( )} {user && chapters[0].isFullMatchChapter && ( )}
) }