diff --git a/src/features/bbs/components/MediaDetail.tsx b/src/features/bbs/components/MediaDetail.tsx index ebe12da..118eea8 100644 --- a/src/features/bbs/components/MediaDetail.tsx +++ b/src/features/bbs/components/MediaDetail.tsx @@ -30,19 +30,23 @@ const seekOnDoubleTap = (e: TouchEvent) => { 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 ref = useRef(null); - const [fast, setFast] = useState(false); - const toggle = () => { - if (ref.current) ref.current.playbackRate = fast ? 1 : 2; - setFast(!fast); + const [speed, setSpeed] = useState(1); + const next = () => { + const s = SPEEDS[(SPEEDS.indexOf(speed) + 1) % SPEEDS.length]; + if (ref.current) ref.current.playbackRate = s; + setSpeed(s); }; return (
); diff --git a/src/features/bbs/components/bbs.module.css b/src/features/bbs/components/bbs.module.css index 588ede6..cbd2548 100644 --- a/src/features/bbs/components/bbs.module.css +++ b/src/features/bbs/components/bbs.module.css @@ -113,7 +113,7 @@ .videoBox { position: relative; width: fit-content; max-width: 100%; margin: 0.6em 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[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 a { text-decoration: none; }