feat(in-132): player bugfix

pull/24/head
Rita 3 years ago committed by Andrei Dekterev
parent ed9cf58569
commit 5b75d10390
  1. 14
      src/features/MatchPage/store/hooks/index.tsx
  2. 6
      src/features/StreamPlayer/hooks/index.tsx
  3. 13
      src/features/StreamPlayer/hooks/useHlsPlayer.tsx

@ -8,12 +8,13 @@ import includes from 'lodash/includes'
import filter from 'lodash/filter'
import isEmpty from 'lodash/isEmpty'
import { useToggle } from 'hooks'
import { FULL_GAME_KEY } from 'features/MatchPage/helpers/buildPlaylists'
import type { MatchInfo } from 'requests/getMatchInfo'
import { getMatchInfo } from 'requests/getMatchInfo'
import { usePageParams } from 'hooks/usePageParams'
import { useToggle } from 'hooks/useToggle'
import { parseDate } from 'helpers/parseDate'
@ -63,6 +64,17 @@ export const useMatchPage = () => {
return () => clearInterval(getIntervalMatch)
}, [matchProfile, sportType, matchId])
useEffect(() => {
let getIntervalMatch: ReturnType<typeof setInterval>
if (matchProfile?.live && selectedPlaylist?.id === FULL_GAME_KEY
) {
getIntervalMatch = setInterval(
() => getMatchInfo(sportType, matchId).then(setMatchProfile), 5000,
)
}
return () => clearInterval(getIntervalMatch)
})
const {
events,
handlePlaylistClick,

@ -102,7 +102,11 @@ export const useVideoPlayer = ({
const { url } = chapters[0] ?? { url: '' }
const numberOfChapters = size(chapters)
const { hls, videoRef } = useHlsPlayer(url, resumeFrom)
const { hls, videoRef } = useHlsPlayer({
isLive,
resumeFrom,
src: url,
})
const [isLiveTime, setIsLiveTime] = useState(false)
const [isPausedTime, setIsPausedTime] = useState(false)
const [pausedProgress, setPausedProgress] = useState(0)

@ -9,7 +9,17 @@ import isNumber from 'lodash/isNumber'
import { streamConfig } from '../config'
export const useHlsPlayer = (src: string, resumeFrom?: number) => {
type useHlsPlayerType = {
isLive?: boolean,
resumeFrom?: number,
src: string,
}
export const useHlsPlayer = ({
isLive,
resumeFrom,
src,
}: useHlsPlayerType) => {
const hls = useMemo(() => {
if (!Hls.isSupported()) return null
@ -35,6 +45,7 @@ export const useHlsPlayer = (src: string, resumeFrom?: number) => {
return {
hls,
isLive,
videoRef,
}
}

Loading…
Cancel
Save