Skip to content

Commit

Permalink
fix: added ts pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
amar-1995 committed Mar 12, 2024
1 parent 2d74a0a commit 9ce3e72
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions packages/roomkit-react/src/Prebuilt/layouts/HLSView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,21 +337,27 @@ const HLSView = () => {
[hlsState?.variants, isLandscape, isMobile, onSeekTo],
);
const onClickHandler = useCallback(async () => {
if (!(isMobile || isLandscape) && hlsState?.variants[0]?.playlist_type !== HLSPlaylistType.DVR) {
return;
}
if (!(isMobile || isLandscape)) {
if (isPaused) {
await hlsPlayer?.play();
} else {
hlsPlayer.pause();
}
return;
}
setControlsVisible(value => !value);
if (controlsTimerRef.current) {
clearTimeout(controlsTimerRef.current);
}
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();
}
})
.with({ isMobile: true }, () => {
setControlsVisible(value => !value);
if (controlsTimerRef.current) {
clearTimeout(controlsTimerRef.current);
}
})
.with({ isLandscape: true }, () => {
setControlsVisible(value => !value);
if (controlsTimerRef.current) {
clearTimeout(controlsTimerRef.current);
}
})
.otherwise(() => null);
}, [hlsState?.variants, isLandscape, isMobile, isPaused]);
const onHoverHandler = useCallback(
event => {
Expand Down

0 comments on commit 9ce3e72

Please sign in to comment.