From fd492549fbb2b4b677e8308f99c8afb1963b2883 Mon Sep 17 00:00:00 2001 From: amar-1995 Date: Tue, 12 Mar 2024 18:14:35 +0530 Subject: [PATCH] fix: play pause on click event --- .../src/Prebuilt/layouts/HLSView.jsx | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/roomkit-react/src/Prebuilt/layouts/HLSView.jsx b/packages/roomkit-react/src/Prebuilt/layouts/HLSView.jsx index e754cf4958..2be40db094 100644 --- a/packages/roomkit-react/src/Prebuilt/layouts/HLSView.jsx +++ b/packages/roomkit-react/src/Prebuilt/layouts/HLSView.jsx @@ -336,15 +336,26 @@ const HLSView = () => { }, [hlsState?.variants, isLandscape, isMobile, onSeekTo], ); - const onClickHandler = useCallback(() => { - if (!(isMobile || isLandscape)) { - return; - } - setControlsVisible(value => !value); - if (controlsTimerRef.current) { - clearTimeout(controlsTimerRef.current); - } - }, [isLandscape, isMobile]); + const onClickHandler = useCallback(async () => { + match({ isMobile, isLandscape, playlist_type: hlsState?.variants[0]?.playlist_type }) + .with({ playlist_type: HLSPlaylistType.DVR, isMobile: false, isLandscape: false }, async () => { + if (isPaused) { + await hlsPlayer?.play(); + } else { + hlsPlayer?.pause(); + } + }) + .when( + ({ isMobile, isLandscape }) => isMobile || isLandscape, + () => { + setControlsVisible(value => !value); + if (controlsTimerRef.current) { + clearTimeout(controlsTimerRef.current); + } + }, + ) + .otherwise(() => null); + }, [hlsState?.variants, isLandscape, isMobile, isPaused]); const onHoverHandler = useCallback( event => { event.preventDefault();