Skip to content

Commit b258ac6

Browse files
committed
feat: space바로 재생, 정지 아이콘 추가
1 parent 3164c85 commit b258ac6

File tree

5 files changed

+49
-46
lines changed

5 files changed

+49
-46
lines changed
Lines changed: 12 additions & 0 deletions
Loading
Lines changed: 6 additions & 26 deletions
Loading
Lines changed: 5 additions & 17 deletions
Loading

frontend/src/components/client/Player.tsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Hls from 'hls.js';
33
import styled from 'styled-components';
44

55
import playerLoading from '@assets/player_loading.gif';
6-
import CustomPlayIcon from '@assets/custom_play_icon.svg';
6+
import CustomPlayIcon from '@assets/icons/custom_play_icon.svg';
77
import PauseIcon from '@assets/icons/pause_icon.svg';
88
import PlayIcon from '@assets/icons/play_icon.svg';
99

@@ -58,14 +58,37 @@ const Player = ({ videoUrl }: { videoUrl: string }) => {
5858
}
5959
};
6060

61+
useEffect(() => {
62+
const handleKeyDown = (e: KeyboardEvent) => {
63+
if (e.code === 'Space') {
64+
e.preventDefault();
65+
handlePlayPause();
66+
}
67+
};
68+
69+
const videoElement = videoRef.current;
70+
videoElement?.addEventListener('keydown', handleKeyDown);
71+
72+
return () => {
73+
videoElement?.removeEventListener('keydown', handleKeyDown);
74+
};
75+
}, []);
76+
6177
return (
6278
<PlayerContainer $onHLSReady={onHLSReady}>
6379
<LivePlayerInner>
6480
{onHLSReady ? (
6581
<>
66-
<Video ref={videoRef} controls onClick={handlePlayPause} />
82+
<Video
83+
ref={videoRef}
84+
controls
85+
onClick={handlePlayPause}
86+
tabIndex={0} // Video 요소가 포커스를 받을 수 있도록 설정
87+
/>
6788
{showIcon && (
68-
<IconOverlay $isFullscreen={isFullscreen}>{isPaused ? <PlayIcon /> : <PauseIcon />}</IconOverlay>
89+
<IconOverlay $isFullscreen={isFullscreen}>
90+
{isPaused ? <PlayIcon /> : <PauseIcon />}
91+
</IconOverlay>
6992
)}
7093
</>
7194
) : (

0 commit comments

Comments
 (0)