diff --git a/src/features/MatchPage/components/LiveMatch/hooks/index.tsx b/src/features/MatchPage/components/LiveMatch/hooks/index.tsx index 39e1cfdd..73ed9062 100644 --- a/src/features/MatchPage/components/LiveMatch/hooks/index.tsx +++ b/src/features/MatchPage/components/LiveMatch/hooks/index.tsx @@ -1,13 +1,10 @@ -import { useEffect, useState } from 'react' - -import type { LiveVideos } from 'requests' -import { getLiveVideos } from 'requests' - import { useSportNameParam, usePageId, } from 'hooks' +import { API_ROOT } from 'config' + import { usePlayerProgressReporter } from 'features/MatchPage/hooks/usePlayerProgressReporter' import { useLastPlayPosition } from 'features/MatchPage/hooks/useLastPlayPosition' import { useUrlParam } from 'features/MatchPage/hooks/useUrlParam' @@ -17,16 +14,9 @@ export const useLiveMatch = () => { const matchId = usePageId() const resume = useUrlParam() - const [liveVideos, setLiveVideos] = useState([]) - - useEffect(() => { - getLiveVideos(sportType, matchId).then(setLiveVideos) - }, - [sportType, matchId]) - return { - matchUrl: liveVideos[0] || '', resume, + streamUrl: `${API_ROOT}/video/stream/${sportType}/${matchId}.m3u8`, ...usePlayerProgressReporter(), ...useLastPlayPosition(), } diff --git a/src/features/MatchPage/components/LiveMatch/index.tsx b/src/features/MatchPage/components/LiveMatch/index.tsx index ad865cd8..bc7f2f36 100644 --- a/src/features/MatchPage/components/LiveMatch/index.tsx +++ b/src/features/MatchPage/components/LiveMatch/index.tsx @@ -15,10 +15,10 @@ type Props = { export const LiveMatch = ({ profile }: Props) => { const { - matchUrl, onPlayerProgressChange, onPlayingChange, resume, + streamUrl, } = useLiveMatch() return ( @@ -26,7 +26,7 @@ export const LiveMatch = ({ profile }: Props) => { - -export const getLiveVideos = ( - sportType: SportTypes, - matchId: number, -): Promise => { - const config = { - body: { - match_id: matchId, - sport_id: sportType, - }, - } - - return callApi({ - config, - url: `${API_ROOT}/video/stream`, - }).then((videos: LiveVideos) => { - if (isEmpty(videos)) return Promise.reject() - return videos - }) -} diff --git a/src/requests/index.tsx b/src/requests/index.tsx index 7c01182c..6c83620e 100644 --- a/src/requests/index.tsx +++ b/src/requests/index.tsx @@ -18,7 +18,6 @@ export * from './reportPlayerProgress' export * from './getVideos' export * from './saveUserInfo' export * from './getPlayerInfo' -export * from './getLiveVideos' export * from './getMatchLastWatchSeconds' export * from './getMatchesPreviewImages' export * from './getSportActions'