Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added keyboard interaction #2657

Merged
merged 5 commits into from
Mar 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/roomkit-react/src/Prebuilt/layouts/HLSView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,31 @@ const HLSView = () => {
[controlsVisible, isLandscape, isMobile, qualityDropDownOpen, seekProgress],
);

const keyPressHandler = useCallback(
raviteja83 marked this conversation as resolved.
Show resolved Hide resolved
async event => {
if (hlsState?.variants[0]?.playlist_type !== HLSPlaylistType.DVR) {
return;
}
switch (event.key) {
case ' ':
raviteja83 marked this conversation as resolved.
Show resolved Hide resolved
if (isPaused) {
await hlsPlayer?.play();
} else {
hlsPlayer?.pause();
}
break;
case 'ArrowRight':
onSeekTo(10);
break;
case 'ArrowLeft':
onSeekTo(-10);
break;
default:
raviteja83 marked this conversation as resolved.
Show resolved Hide resolved
}
},
[hlsState?.variants, isPaused, onSeekTo],
);

if (!hlsUrl || streamEnded) {
return (
<>
Expand Down Expand Up @@ -437,7 +462,10 @@ const HLSView = () => {
'@md': {
height: 'auto',
},
outline: 'none',
}}
onKeyDown={keyPressHandler}
tabIndex="0"
>
{!(isMobile || isLandscape) && (
<HLSAutoplayBlockedPrompt open={isHlsAutoplayBlocked} unblockAutoPlay={unblockAutoPlay} />
Expand Down
Loading