fix(#video-duration): calculate video duration for unfinished video after live

black-screen
Andrei Dekterev 3 years ago
parent 8e08fbadd9
commit e1a7f05f26
  1. 8
      src/features/MatchPage/components/LiveMatch/helpers.tsx
  2. 1
      src/features/MatchPage/store/hooks/useMatchData.tsx
  3. 4
      src/features/StreamPlayer/hooks/index.tsx

@ -40,11 +40,13 @@ const getFullMatchChapters = ({
? ((playlist.duration ?? 0) - Number(bound.s)) * 1000
: (playlist.duration ?? 0) * 1000
const delayedDuration = Math.max(durationMs, Number(bound?.e ?? 0)) * 1000
return [
{
duration: durationMs,
endMs: durationMs,
endOffsetMs: bound ? Number(bound.e) * 1000 : durationMs,
duration: delayedDuration,
endMs: delayedDuration,
endOffsetMs: delayedDuration,
index: 0,
isFullMatchChapter: true,
startMs: 0,

@ -45,6 +45,7 @@ export const useMatchData = (profile: MatchInfo) => {
const fullMatchDuration = matchDuration
useEffect(() => {
if (!profile || (profile.live && Number(profile.c_match_calc_status) <= 1)) return
fetchMatchPlaylists({
fullMatchDuration,
id: matchId,

@ -363,8 +363,8 @@ export const useVideoPlayer = ({
}, [isLive, chaptersProps[0].startOffsetMs])
useEffect(() => {
if (((isLive || chapters[0].duration === chaptersProps[0].duration)
&& chapters[0]?.endOffsetMs === chaptersProps[0]?.endOffsetMs
if (((isLive || Boolean(Math.round((chapters[0].duration / chaptersProps[0].duration))))
&& Boolean(Math.round(chapters[0]?.endOffsetMs / chaptersProps[0]?.endOffsetMs))
&& chapters[0]?.url.match(regURL)?.[0] === chaptersProps[0]?.url.match(regURL)?.[0])
|| (isEmpty(chapters) || isEmpty(chaptersProps))) return

Loading…
Cancel
Save