|
|
|
|
@ -25,6 +25,7 @@ import { useNoNetworkPopupStore } from 'features/NoNetworkPopup' |
|
|
|
|
import { useLiveMatch } from 'features/MatchPage/components/LiveMatch/hooks' |
|
|
|
|
import { useLexicsStore } from 'features/LexicsStore' |
|
|
|
|
import { useMatchPageStore } from 'features/MatchPage/store' |
|
|
|
|
import { FULL_GAME_KEY } from 'features/MatchPage/helpers/buildPlaylists' |
|
|
|
|
|
|
|
|
|
import { VIEW_INTERVAL_MS, saveMatchStats } from 'requests' |
|
|
|
|
|
|
|
|
|
@ -91,6 +92,7 @@ export const useVideoPlayer = ({ |
|
|
|
|
const { profileId, sportType } = usePageParams() |
|
|
|
|
const { |
|
|
|
|
isPlayFilterEpisodes, |
|
|
|
|
matchPlaylists, |
|
|
|
|
playNextEpisode, |
|
|
|
|
selectedPlaylist, |
|
|
|
|
setCircleAnimation, |
|
|
|
|
@ -187,7 +189,7 @@ export const useVideoPlayer = ({ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const onWaiting = () => { |
|
|
|
|
setPlayerState({ buffering: !ready }) |
|
|
|
|
setPlayerState({ buffering: true }) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const onPlaying = () => { |
|
|
|
|
@ -232,14 +234,8 @@ export const useVideoPlayer = ({ |
|
|
|
|
const backToLive = useCallback(() => { |
|
|
|
|
if (!duration) return |
|
|
|
|
|
|
|
|
|
if (selectedPlaylist?.id !== 'full_game') { |
|
|
|
|
onPlaylistSelect({ |
|
|
|
|
duration: 0, |
|
|
|
|
episodes: [], |
|
|
|
|
id: 'full_game', |
|
|
|
|
lexic: 13028, |
|
|
|
|
type: 0, |
|
|
|
|
}) |
|
|
|
|
if (selectedPlaylist?.id !== FULL_GAME_KEY) { |
|
|
|
|
onPlaylistSelect(matchPlaylists.match[0]) |
|
|
|
|
setIsLiveTime(true) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -251,19 +247,14 @@ export const useVideoPlayer = ({ |
|
|
|
|
onPlaylistSelect, |
|
|
|
|
selectedPlaylist, |
|
|
|
|
setPlayerState, |
|
|
|
|
matchPlaylists.match, |
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
const backToPausedTime = useCallback(() => { |
|
|
|
|
if (!duration) return |
|
|
|
|
|
|
|
|
|
if (selectedPlaylist?.id !== 'full_game') { |
|
|
|
|
onPlaylistSelect({ |
|
|
|
|
duration: 0, |
|
|
|
|
episodes: [], |
|
|
|
|
id: 'full_game', |
|
|
|
|
lexic: 13028, |
|
|
|
|
type: 0, |
|
|
|
|
}) |
|
|
|
|
if (selectedPlaylist?.id !== FULL_GAME_KEY) { |
|
|
|
|
onPlaylistSelect(matchPlaylists.match[0]) |
|
|
|
|
setIsPausedTime(true) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -276,11 +267,12 @@ export const useVideoPlayer = ({ |
|
|
|
|
onPlaylistSelect, |
|
|
|
|
selectedPlaylist, |
|
|
|
|
setPlayerState, |
|
|
|
|
matchPlaylists.match, |
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (chapters[0]?.isFullMatchChapter) { |
|
|
|
|
setPausedProgress(playedProgress) |
|
|
|
|
setPausedProgress(playedProgress + chapters[0].startOffsetMs) |
|
|
|
|
} |
|
|
|
|
// eslint-disable-next-line
|
|
|
|
|
}, [selectedPlaylist]) |
|
|
|
|
@ -357,11 +349,11 @@ export const useVideoPlayer = ({ |
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if ((isLive && chapters[0]?.isFullMatchChapter) || isEmpty(chapters)) return |
|
|
|
|
if ((chapters[0]?.isFullMatchChapter) || isEmpty(chapters)) return |
|
|
|
|
|
|
|
|
|
const { duration: chapterDuration } = getActiveChapter() |
|
|
|
|
if (playedProgress >= chapterDuration && !seeking && !isPlayFilterEpisodes) { |
|
|
|
|
if (isLive && isLastChapterPlaying) { |
|
|
|
|
if (isLastChapterPlaying) { |
|
|
|
|
backToPausedTime() |
|
|
|
|
} else { |
|
|
|
|
playNextChapter() |
|
|
|
|
@ -406,7 +398,7 @@ export const useVideoPlayer = ({ |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (!navigator.serviceWorker || !isIOS) return undefined |
|
|
|
|
const listener = (event: MessageEvent) => { |
|
|
|
|
const listener = (event: MessageEvent<{ duration: number }>) => { |
|
|
|
|
setPlayerState({ duration: toMilliSeconds(event.data.duration) }) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|