feat(in-130): watch all bug fix

IN-146-filter-matches
Rita 3 years ago
parent 1301692118
commit 9a0e5f92d2
  1. 4
      src/features/MatchPage/components/LiveMatch/hooks/index.tsx
  2. 10
      src/features/MatchPage/components/LiveMatch/index.tsx
  3. 38
      src/features/StreamPlayer/hooks/index.tsx

@ -16,6 +16,8 @@ import { usePlaylistLogger } from './usePlaylistLogger'
export const useLiveMatch = () => { export const useLiveMatch = () => {
const { const {
handlePlaylistClick, handlePlaylistClick,
isPlayFilterEpisodes,
playNextEpisode,
profile, profile,
selectedPlaylist, selectedPlaylist,
setFullMatchPlaylistDuration, setFullMatchPlaylistDuration,
@ -66,10 +68,12 @@ export const useLiveMatch = () => {
return { return {
chapters, chapters,
isPlayFilterEpisodes,
onDurationChange, onDurationChange,
onPlayerProgressChange, onPlayerProgressChange,
onPlayingChange, onPlayingChange,
onPlaylistSelect, onPlaylistSelect,
playNextEpisode,
resume: resume ?? fromStartIfStreamPaused, resume: resume ?? fromStartIfStreamPaused,
selectedPlaylist, selectedPlaylist,
streamUrl: `${API_ROOT}/video/stream/${sportType}/${matchId}.m3u8`, streamUrl: `${API_ROOT}/video/stream/${sportType}/${matchId}.m3u8`,

@ -1,7 +1,9 @@
import { Fragment } from 'react' import { Fragment, useState } from 'react'
import isEmpty from 'lodash/isEmpty' import isEmpty from 'lodash/isEmpty'
import type { TCircleAnimation } from 'features/CircleAnimationBar'
import { initialCircleAnimation } from 'features/CircleAnimationBar'
import { useMatchPageStore } from 'features/MatchPage/store' import { useMatchPageStore } from 'features/MatchPage/store'
import { StreamPlayer } from 'features/StreamPlayer' import { StreamPlayer } from 'features/StreamPlayer'
import { YoutubePlayer } from 'features/StreamPlayer/components/YoutubePlayer' import { YoutubePlayer } from 'features/StreamPlayer/components/YoutubePlayer'
@ -13,6 +15,8 @@ import { useLiveMatch } from './hooks'
import { MatchDescription } from '../MatchDescription' import { MatchDescription } from '../MatchDescription'
export const LiveMatch = () => { export const LiveMatch = () => {
const [circleAnimation, setCircleAnimation] = useState<TCircleAnimation>(initialCircleAnimation)
const { const {
profile, profile,
selectedPlaylist, selectedPlaylist,
@ -39,10 +43,12 @@ export const LiveMatch = () => {
onProgressChange={onPlayerProgressChange} onProgressChange={onPlayerProgressChange}
resumeFrom={resume} resumeFrom={resume}
url={streamUrl} url={streamUrl}
setCircleAnimation={setCircleAnimation}
/> />
) : ( ) : (
!isEmpty(chapters) && ( !isEmpty(chapters) && (
<StreamPlayer <StreamPlayer
setCircleAnimation={setCircleAnimation}
onDurationChange={onDurationChange} onDurationChange={onDurationChange}
onPlayingChange={onPlayingChange} onPlayingChange={onPlayingChange}
onProgressChange={onPlayerProgressChange} onProgressChange={onPlayerProgressChange}
@ -56,6 +62,8 @@ export const LiveMatch = () => {
</Container> </Container>
<MatchSidePlaylists <MatchSidePlaylists
setCircleAnimation={setCircleAnimation}
circleAnimation={circleAnimation}
onSelect={onPlaylistSelect} onSelect={onPlaylistSelect}
selectedPlaylist={selectedPlaylist} selectedPlaylist={selectedPlaylist}
/> />

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

Loading…
Cancel
Save