feat : 자료실 영상 속도 버튼 0.5x·1x·2x·3x 순환
SpecialSource Frontend (React) CD / deploy (push) Successful in 13s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
headporterandClaude Opus 5.5 committed 2026-12-04 10:08:43 +09:00
1 parent dbaedafb0b
commit ecc13f5d66
2 files changed
+12 -8

No files matched your search

+11 -7
View File
@@ -30,19 +30,23 @@ const seekOnDoubleTap = (e: TouchEvent<HTMLVideoElement>) => {
v.currentTime = Math.max(0, v.currentTime + (touch.clientX - rect.left < rect.width / 2 ? -5 : 5)); v.currentTime = Math.max(0, v.currentTime + (touch.clientX - rect.left < rect.width / 2 ? -5 : 5));
}; };
/** 영상 + 오른쪽 위 2배속 버튼 (누를 때마다 1x ↔ 2x). 전체화면에서는 버튼이 안 보임 → 브라우저 ⋮ 메뉴 사용 */ /** 재생 속도 버튼이 누를 때마다 도는 순서 */
const SPEEDS = [1, 2, 3, 0.5];
/** 영상 + 오른쪽 위 속도 버튼 (1x → 2x → 3x → 0.5x → 1x). 전체화면에서는 버튼이 안 보임 → 브라우저 ⋮ 메뉴 사용 */
const Video = ({ src, autoPlay }: { src: string; autoPlay: boolean }) => { const Video = ({ src, autoPlay }: { src: string; autoPlay: boolean }) => {
const ref = useRef<HTMLVideoElement>(null); const ref = useRef<HTMLVideoElement>(null);
const [fast, setFast] = useState(false); const [speed, setSpeed] = useState(1);
const toggle = () => { const next = () => {
if (ref.current) ref.current.playbackRate = fast ? 1 : 2; const s = SPEEDS[(SPEEDS.indexOf(speed) + 1) % SPEEDS.length];
setFast(!fast); if (ref.current) ref.current.playbackRate = s;
setSpeed(s);
}; };
return ( return (
<div className={styles.videoBox}> <div className={styles.videoBox}>
<video ref={ref} src={src} controls preload="metadata" playsInline loop autoPlay={autoPlay} onTouchEnd={seekOnDoubleTap} /> <video ref={ref} src={src} controls preload="metadata" playsInline loop autoPlay={autoPlay} onTouchEnd={seekOnDoubleTap} />
<button type="button" className={styles.speed} onClick={toggle} aria-pressed={fast}> <button type="button" className={styles.speed} onClick={next} aria-label={`재생 속도 ${speed}배, 누르면 변경`} data-changed={speed !== 1}>
{fast ? "2x" : "1x"} {speed}x
</button> </button>
</div> </div>
); );
+1 -1
View File
@@ -113,7 +113,7 @@
.videoBox { position: relative; width: fit-content; max-width: 100%; margin: 0.6em 0; } .videoBox { position: relative; width: fit-content; max-width: 100%; margin: 0.6em 0; }
.videoBox video { margin: 0; } .videoBox video { margin: 0; }
.speed { position: absolute; top: 8px; right: 8px; padding: 0 6px; font: inherit; color: var(--bbs-hi); background: rgb(0 0 0 / 0.6); border: 1px solid var(--bbs-hi); cursor: pointer; } .speed { position: absolute; top: 8px; right: 8px; padding: 0 6px; font: inherit; color: var(--bbs-hi); background: rgb(0 0 0 / 0.6); border: 1px solid var(--bbs-hi); cursor: pointer; }
.speed[aria-pressed="true"] { color: var(--bbs-highlight); border-color: var(--bbs-highlight); } .speed[data-changed="true"] { color: var(--bbs-highlight); border-color: var(--bbs-highlight); }
/* 자료실 받기 목록 */ /* 자료실 받기 목록 */
.files { list-style: none; margin: 0; padding: 0; overflow-wrap: anywhere; } .files { list-style: none; margin: 0; padding: 0; overflow-wrap: anywhere; }
.files a { text-decoration: none; } .files a { text-decoration: none; }