fix(#299): change color for live button progress

pull/143/head
Andrei Dekterev 3 years ago
parent 8a46f0a363
commit 27002909a5
  1. 2
      src/features/ProfileCard/index.tsx
  2. 6
      src/features/StreamPlayer/components/Controls/Components/ControlsWeb/index.tsx
  3. 1
      src/features/StreamPlayer/components/Controls/index.tsx
  4. 8
      src/features/StreamPlayer/hooks/index.tsx
  5. 2
      src/features/StreamPlayer/index.tsx
  6. 8
      src/features/StreamPlayer/styled.tsx

@ -79,7 +79,7 @@ export const ProfileCard = ({ profile }: ProfileType) => {
<Details> <Details>
<ProfileName>{name}</ProfileName> <ProfileName>{name}</ProfileName>
<InfoItems> <InfoItems>
{profile.additionalInfo?.id && <InfoFlag src={`${URL_AWS}/media/flags/${profile.additionalInfo?.id}.png`} />} {profile.additionalInfo?.id && <InfoFlag src={`${URL_AWS}/media/flags/${profile.additionalInfo.id}.png`} />}
{tournamentId {tournamentId
? ( ? (
<StyledLink <StyledLink

@ -39,6 +39,7 @@ export const ControlsWeb = (controlsProps: { props: ControlsPropsExtended }) =>
isFullscreen, isFullscreen,
isLastChapterPlaying, isLastChapterPlaying,
isLive, isLive,
isLiveTime,
isStorage, isStorage,
muted, muted,
numberOfChapters = 0, numberOfChapters = 0,
@ -108,7 +109,10 @@ export const ControlsWeb = (controlsProps: { props: ControlsPropsExtended }) =>
selectedAudioTrack={selectedAudioTrack!} selectedAudioTrack={selectedAudioTrack!}
/> />
{isLive && ( {isLive && (
<LiveBtn onClick={backToLive}> <LiveBtn
onClick={backToLive}
isLiveTime={isLiveTime}
>
<T9n t='live' /> <T9n t='live' />
</LiveBtn> </LiveBtn>
)} )}

@ -29,6 +29,7 @@ export type ControlsProps = {
isFullscreen: boolean, isFullscreen: boolean,
isLastChapterPlaying?: boolean, isLastChapterPlaying?: boolean,
isLive?: boolean, isLive?: boolean,
isLiveTime?: boolean,
isStorage?: boolean, isStorage?: boolean,
liveChapters?: LiveChapters, liveChapters?: LiveChapters,
loadedProgress: number, loadedProgress: number,

@ -44,6 +44,7 @@ import { FULL_GAME_KEY } from '../../MatchPage/helpers/buildPlaylists'
export type PlayerState = typeof initialState export type PlayerState = typeof initialState
const toMilliSeconds = (seconds: number) => seconds * 1000 const toMilliSeconds = (seconds: number) => seconds * 1000
const BUFFERING_TIME = 30 * 1000
const initialState = { const initialState = {
activeChapterIndex: 0, activeChapterIndex: 0,
@ -61,6 +62,7 @@ const initialState = {
export type Props = { export type Props = {
chapters: Chapters, chapters: Chapters,
isLive: boolean, isLive: boolean,
isLiveTime?: boolean,
onDurationChange?: (duration: number) => void, onDurationChange?: (duration: number) => void,
onPlayingChange: (playing: boolean) => void, onPlayingChange: (playing: boolean) => void,
onProgressChange: (seconds: number) => void, onProgressChange: (seconds: number) => void,
@ -245,7 +247,7 @@ export const useVideoPlayer = ({
setIsLiveTime(true) setIsLiveTime(true)
} }
const liveProgressMs = Math.max(fullMatchDuration - 30000, 0) const liveProgressMs = Math.max(fullMatchDuration - BUFFERING_TIME, 0)
setPlayerState({ playedProgress: liveProgressMs, seek: liveProgressMs / 1000 }) setPlayerState({ playedProgress: liveProgressMs, seek: liveProgressMs / 1000 })
if (liveProgressMs > 0) setIsLiveTime(false) if (liveProgressMs > 0) setIsLiveTime(false)
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
@ -265,7 +267,7 @@ export const useVideoPlayer = ({
setIsPausedTime(true) setIsPausedTime(true)
} }
const liveProgressMs = Math.max(duration - 30000, 0) const liveProgressMs = Math.max(duration - BUFFERING_TIME, 0)
setPlayerState({ playedProgress: pausedProgress, seek: pausedProgress / 1000 }) setPlayerState({ playedProgress: pausedProgress, seek: pausedProgress / 1000 })
if (liveProgressMs > 0) setIsPausedTime(false) if (liveProgressMs > 0) setIsPausedTime(false)
// eslint-disable-next-line // eslint-disable-next-line
@ -356,6 +358,7 @@ export const useVideoPlayer = ({
]) ])
useEffect(() => { useEffect(() => {
setIsLiveTime(playedProgress > duration - BUFFERING_TIME)
if ((chapters[0]?.isFullMatchChapter) || isEmpty(chapters)) return if ((chapters[0]?.isFullMatchChapter) || isEmpty(chapters)) return
const { duration: chapterDuration } = getActiveChapter() const { duration: chapterDuration } = getActiveChapter()
@ -491,6 +494,7 @@ export const useVideoPlayer = ({
isFullscreen, isFullscreen,
isLastChapterPlaying, isLastChapterPlaying,
isLive, isLive,
isLiveTime,
loadedProgress, loadedProgress,
numberOfChapters, numberOfChapters,
onDuration, onDuration,

@ -55,6 +55,7 @@ export const StreamPlayer = (props: Props) => {
hideCenterControls, hideCenterControls,
isFullscreen, isFullscreen,
isLive, isLive,
isLiveTime,
loadedProgress, loadedProgress,
mainControlsVisible, mainControlsVisible,
muted, muted,
@ -180,6 +181,7 @@ export const StreamPlayer = (props: Props) => {
duration={duration} duration={duration}
isFullscreen={isFullscreen} isFullscreen={isFullscreen}
isLive={profile?.live} isLive={profile?.live}
isLiveTime={isLiveTime}
isStorage={profile?.storage} isStorage={profile?.storage}
loadedProgress={loadedProgress} loadedProgress={loadedProgress}
muted={muted} muted={muted}

@ -323,7 +323,7 @@ export const CenterControls = styled.div<CenterControlsProps>`
`} `}
` `
export const LiveBtn = styled(ButtonBase)` export const LiveBtn = styled(ButtonBase)<{isLiveTime?: boolean}>`
height: auto; height: auto;
font-weight: bold; font-weight: bold;
font-size: 10px; font-size: 10px;
@ -331,7 +331,11 @@ export const LiveBtn = styled(ButtonBase)`
letter-spacing: 0.05em; letter-spacing: 0.05em;
text-transform: uppercase; text-transform: uppercase;
padding: 4.5px 8px; padding: 4.5px 8px;
background-color: #CC0000; background-color: ${({ isLiveTime }) => (
isLiveTime
? '#CC0000'
: 'rgba(130, 130, 130, 0.6)'
)};
border-radius: 1.3px; border-radius: 1.3px;
margin-right: 25px; margin-right: 25px;

Loading…
Cancel
Save