Skip to content

Commit

Permalink
fix: play pause hls stream on click
Browse files Browse the repository at this point in the history
  • Loading branch information
amar-1995 authored Mar 12, 2024
1 parent 1930311 commit 0431d3a
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions packages/roomkit-react/src/Prebuilt/layouts/HLSView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 0431d3a

Please sign in to comment.