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