From 1545e03e5842877b45f82940eb4a0d3bd82a92f4 Mon Sep 17 00:00:00 2001 From: boyvanov Date: Mon, 20 Sep 2021 17:10:20 +0300 Subject: [PATCH] feat(ott-1590): adding autoplay --- .../MultiSourcePlayer/hooks/index.tsx | 19 ++++++++++--------- src/features/MultiSourcePlayer/index.tsx | 3 --- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/features/MultiSourcePlayer/hooks/index.tsx b/src/features/MultiSourcePlayer/hooks/index.tsx index 476a4265..fa4f1425 100644 --- a/src/features/MultiSourcePlayer/hooks/index.tsx +++ b/src/features/MultiSourcePlayer/hooks/index.tsx @@ -9,6 +9,7 @@ import size from 'lodash/size' import { useFullscreen } from 'features/StreamPlayer/hooks/useFullscreen' import { useVolume } from 'features/VideoPlayer/hooks/useVolume' +import { useMatchPopupStore } from 'features/MatchPopup' import { useObjectState } from 'hooks' @@ -70,7 +71,6 @@ export const useMultiSourcePlayer = ({ playNextChapter, playPrevChapter, startPlaying, - stopPlaying, togglePlaying, } = usePlayingHandlers(setPlayerState, numberOfChapters) @@ -83,9 +83,8 @@ export const useMultiSourcePlayer = ({ const duration = useDuration(chapters) const handleError = useCallback(() => { - stopPlaying() onError?.() - }, [onError, stopPlaying]) + }, [onError]) const getActiveChapter = useCallback( (index: number = activeChapterIndex) => chapters[index], @@ -171,10 +170,6 @@ export const useMultiSourcePlayer = ({ playNextChapter() } - const onPause = () => { - setPlayerState({ playing: false }) - } - useEffect(() => { onPlayingChange(playing) }, [playing, onPlayingChange]) @@ -200,6 +195,14 @@ export const useMultiSourcePlayer = ({ playNextChapter, ]) + const { selectedPlaylist } = useMatchPopupStore() + + useEffect(() => { + if (selectedPlaylist) { + startPlaying() + } + }, [selectedPlaylist, startPlaying]) + return { activeChapterIndex, activePlayer, @@ -215,7 +218,6 @@ export const useMultiSourcePlayer = ({ onEnded, onError: handleError, onLoadedProgress, - onPause, onPlayedProgress, onPlayerClick, onProgressChange, @@ -230,7 +232,6 @@ export const useMultiSourcePlayer = ({ rewindForward, seek, selectedQuality, - startPlaying, togglePlaying, video1Ref, video2Ref, diff --git a/src/features/MultiSourcePlayer/index.tsx b/src/features/MultiSourcePlayer/index.tsx index da476e9c..f21d2fbb 100644 --- a/src/features/MultiSourcePlayer/index.tsx +++ b/src/features/MultiSourcePlayer/index.tsx @@ -52,7 +52,6 @@ export const MultiSourcePlayer = (props: Props) => { onError, onFullscreenClick, onLoadedProgress, - onPause, onPlayedProgress, onPlayerClick, onProgressChange, @@ -105,7 +104,6 @@ export const MultiSourcePlayer = (props: Props) => { onLoadedProgress={firstPlayerActive ? onLoadedProgress : undefined} onPlayedProgress={firstPlayerActive ? onPlayedProgress : undefined} onEnded={onEnded} - onPause={onPause} onError={onError} onReady={onReady} /> @@ -121,7 +119,6 @@ export const MultiSourcePlayer = (props: Props) => { onLoadedProgress={!firstPlayerActive ? onLoadedProgress : undefined} onPlayedProgress={!firstPlayerActive ? onPlayedProgress : undefined} onEnded={onEnded} - onPause={onPause} onError={onError} onReady={onReady} />