You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
spa_instat_tv/src/features/MatchPage/components/LiveMatch/index.tsx

64 lines
1.6 KiB

import { Fragment } from 'react'
import type { Events } from 'requests/getMatchEvents'
import type { MatchInfo } from 'requests/getMatchInfo'
import { StreamPlayer } from 'features/StreamPlayer'
import { YoutubePlayer } from 'features/StreamPlayer/components/YoutubePlayer'
import { MatchSidePlaylists } from 'features/MatchSidePlaylists'
import { isMobileDevice } from 'config/userAgent'
import { Container } from '../../styled'
import { useLiveMatch } from './hooks'
import { TournamentData } from '../../types'
import { MatchProfileCardMobile } from '../MatchProfileCardMobile'
type Props = {
events: Events,
profile: MatchInfo,
tournamentData: TournamentData,
}
export const LiveMatch = ({
events,
profile,
tournamentData,
}: Props) => {
const {
matchPlaylists,
onPlayerProgressChange,
onPlayingChange,
onPlaylistSelect,
resume,
selectedPlaylist,
streamUrl,
} = useLiveMatch(profile)
const Player = profile?.youtube_link ? YoutubePlayer : StreamPlayer
return (
<Fragment>
<Container>
<Player
onPlayingChange={onPlayingChange}
onProgressChange={onPlayerProgressChange}
profile={profile}
resumeFrom={resume}
url={streamUrl}
/>
{isMobileDevice ? <MatchProfileCardMobile profile={profile} /> : null}
</Container>
<MatchSidePlaylists
tournamentData={tournamentData}
events={events}
onSelect={onPlaylistSelect}
playlists={matchPlaylists}
profile={profile}
selectedPlaylist={selectedPlaylist}
/>
</Fragment>
)
}