|
|
|
|
@ -14,13 +14,13 @@ import { isIOS } from 'config/userAgent' |
|
|
|
|
import { useObjectState } from 'hooks/useObjectState' |
|
|
|
|
import { useEventListener } from 'hooks/useEventListener' |
|
|
|
|
|
|
|
|
|
import type { TSetCircleAnimation } from 'features/CircleAnimationBar' |
|
|
|
|
import type { Chapters } from 'features/StreamPlayer/types' |
|
|
|
|
import { useVolume } from 'features/VideoPlayer/hooks/useVolume' |
|
|
|
|
import { useNoNetworkPopupStore } from 'features/NoNetworkPopup' |
|
|
|
|
import { useLiveMatch } from 'features/MatchPage/components/LiveMatch/hooks' |
|
|
|
|
|
|
|
|
|
import type { Chapters } from 'features/StreamPlayer/types' |
|
|
|
|
|
|
|
|
|
import { useLexicsStore } from 'features/LexicsStore' |
|
|
|
|
|
|
|
|
|
import { REWIND_SECONDS } from '../config' |
|
|
|
|
import { useHlsPlayer } from './useHlsPlayer' |
|
|
|
|
import { useFullscreen } from './useFullscreen' |
|
|
|
|
@ -54,6 +54,7 @@ export type Props = { |
|
|
|
|
onPlayingChange: (playing: boolean) => void, |
|
|
|
|
onProgressChange: (seconds: number) => void, |
|
|
|
|
resumeFrom?: number, |
|
|
|
|
setCircleAnimation: TSetCircleAnimation, |
|
|
|
|
url?: string, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -64,6 +65,7 @@ export const useVideoPlayer = ({ |
|
|
|
|
onPlayingChange, |
|
|
|
|
onProgressChange: progressChangeCallback, |
|
|
|
|
resumeFrom, |
|
|
|
|
setCircleAnimation, |
|
|
|
|
}: Props) => { |
|
|
|
|
const [{ |
|
|
|
|
activeChapterIndex, |
|
|
|
|
@ -78,7 +80,12 @@ export const useVideoPlayer = ({ |
|
|
|
|
seeking, |
|
|
|
|
}, setPlayerState] = useObjectState({ ...initialState, chapters: chaptersProps }) |
|
|
|
|
|
|
|
|
|
const { onPlaylistSelect, selectedPlaylist } = useLiveMatch() |
|
|
|
|
const { |
|
|
|
|
isPlayFilterEpisodes, |
|
|
|
|
onPlaylistSelect, |
|
|
|
|
playNextEpisode, |
|
|
|
|
selectedPlaylist, |
|
|
|
|
} = useLiveMatch() |
|
|
|
|
|
|
|
|
|
const { lang } = useLexicsStore() |
|
|
|
|
|
|
|
|
|
@ -326,13 +333,17 @@ export const useVideoPlayer = ({ |
|
|
|
|
if ((isLive && chapters[0]?.isFullMatchChapter) || isEmpty(chapters)) return |
|
|
|
|
|
|
|
|
|
const { duration: chapterDuration } = getActiveChapter() |
|
|
|
|
if (playedProgress >= chapterDuration && !seeking) { |
|
|
|
|
if (playedProgress >= chapterDuration && !seeking && !isPlayFilterEpisodes) { |
|
|
|
|
if (isLive && isLastChapterPlaying) { |
|
|
|
|
backToPausedTime() |
|
|
|
|
} else { |
|
|
|
|
playNextChapter() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (playedProgress >= chapterDuration && !seeking && isPlayFilterEpisodes) { |
|
|
|
|
setPlayerState({ playedProgress: 0 }) |
|
|
|
|
playNextEpisode() |
|
|
|
|
} |
|
|
|
|
// eslint-disable-next-line
|
|
|
|
|
}, [ |
|
|
|
|
isLive, |
|
|
|
|
@ -342,6 +353,8 @@ export const useVideoPlayer = ({ |
|
|
|
|
playedProgress, |
|
|
|
|
seeking, |
|
|
|
|
playNextChapter, |
|
|
|
|
playNextEpisode, |
|
|
|
|
isPlayFilterEpisodes, |
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
const { isOnline } = useNoNetworkPopupStore() |
|
|
|
|
@ -385,6 +398,21 @@ export const useVideoPlayer = ({ |
|
|
|
|
} |
|
|
|
|
}, [ready, videoRef]) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (!setCircleAnimation) return |
|
|
|
|
setCircleAnimation((state) => ({ |
|
|
|
|
...state, |
|
|
|
|
playedProgress, |
|
|
|
|
playing, |
|
|
|
|
ready, |
|
|
|
|
})) |
|
|
|
|
}, [ |
|
|
|
|
playedProgress, |
|
|
|
|
playing, |
|
|
|
|
ready, |
|
|
|
|
setCircleAnimation, |
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
const warningText = lang === 'es' |
|
|
|
|
? 'La transmisión en vivo no está disponible temporalmente en dispositivos iOS' |
|
|
|
|
: 'Live streaming is temporarily unavailable on iOS devices' |
|
|
|
|
|