Skip to content

Commit

Permalink
feat: space바로 재생, 정지 아이콘 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
spearStr committed Nov 14, 2024
1 parent 3164c85 commit b258ac6
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 46 deletions.
File renamed without changes
12 changes: 12 additions & 0 deletions frontend/src/assets/icons/live_pause_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 6 additions & 26 deletions frontend/src/assets/icons/pause_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 5 additions & 17 deletions frontend/src/assets/icons/play_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 26 additions & 3 deletions frontend/src/components/client/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Hls from 'hls.js';
import styled from 'styled-components';

import playerLoading from '@assets/player_loading.gif';
import CustomPlayIcon from '@assets/custom_play_icon.svg';
import CustomPlayIcon from '@assets/icons/custom_play_icon.svg';
import PauseIcon from '@assets/icons/pause_icon.svg';
import PlayIcon from '@assets/icons/play_icon.svg';

Expand Down Expand Up @@ -58,14 +58,37 @@ const Player = ({ videoUrl }: { videoUrl: string }) => {
}
};

useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if (e.code === 'Space') {
e.preventDefault();
handlePlayPause();
}
};

const videoElement = videoRef.current;
videoElement?.addEventListener('keydown', handleKeyDown);

return () => {
videoElement?.removeEventListener('keydown', handleKeyDown);
};
}, []);

return (
<PlayerContainer $onHLSReady={onHLSReady}>
<LivePlayerInner>
{onHLSReady ? (
<>
<Video ref={videoRef} controls onClick={handlePlayPause} />
<Video
ref={videoRef}
controls
onClick={handlePlayPause}
tabIndex={0} // Video 요소가 포커스를 받을 수 있도록 설정
/>
{showIcon && (
<IconOverlay $isFullscreen={isFullscreen}>{isPaused ? <PlayIcon /> : <PauseIcon />}</IconOverlay>
<IconOverlay $isFullscreen={isFullscreen}>
{isPaused ? <PlayIcon /> : <PauseIcon />}
</IconOverlay>
)}
</>
) : (
Expand Down

0 comments on commit b258ac6

Please sign in to comment.