|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
import type { MouseEvent } from 'react' |
|
|
|
|
import { |
|
|
|
|
useRef, |
|
|
|
|
useCallback, |
|
|
|
|
useEffect, |
|
|
|
|
useState, |
|
|
|
|
@ -25,7 +26,7 @@ import { useNoNetworkPopupStore } from 'features/NoNetworkPopup' |
|
|
|
|
import { useLiveMatch } from 'features/MatchPage/components/LiveMatch/hooks' |
|
|
|
|
import { useLexicsStore } from 'features/LexicsStore' |
|
|
|
|
|
|
|
|
|
import { intervalMs, saveMatchStats } from 'requests' |
|
|
|
|
import { VIEW_INTERVAL_MS, saveMatchStats } from 'requests' |
|
|
|
|
|
|
|
|
|
import { REWIND_SECONDS } from '../config' |
|
|
|
|
import { useHlsPlayer } from './useHlsPlayer' |
|
|
|
|
@ -96,6 +97,9 @@ export const useVideoPlayer = ({ |
|
|
|
|
const { lang } = useLexicsStore() |
|
|
|
|
const { profileId, sportType } = usePageParams() |
|
|
|
|
|
|
|
|
|
/** время для сохранения статистики просмотра матча */ |
|
|
|
|
const timeForStatistics = useRef(0) |
|
|
|
|
|
|
|
|
|
const { url } = chapters[0] ?? { url: '' } |
|
|
|
|
const numberOfChapters = size(chapters) |
|
|
|
|
const { hls, videoRef } = useHlsPlayer({ |
|
|
|
|
@ -219,6 +223,7 @@ export const useVideoPlayer = ({ |
|
|
|
|
const chapter = getActiveChapter() |
|
|
|
|
const value = Math.max(playedMs - chapter.startOffsetMs, 0) |
|
|
|
|
setPlayerState({ playedProgress: value }) |
|
|
|
|
timeForStatistics.current = (value + chapter.startMs) / 1000 |
|
|
|
|
|
|
|
|
|
progressChangeCallback(value / 1000) |
|
|
|
|
} |
|
|
|
|
@ -443,11 +448,11 @@ export const useVideoPlayer = ({ |
|
|
|
|
callback: () => { |
|
|
|
|
saveMatchStats({ |
|
|
|
|
matchId: profileId, |
|
|
|
|
matchSecond: videoRef.current?.currentTime!, |
|
|
|
|
matchSecond: timeForStatistics.current, |
|
|
|
|
sportType, |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
intervalDuration: intervalMs, |
|
|
|
|
intervalDuration: VIEW_INTERVAL_MS, |
|
|
|
|
startImmediate: false, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|