diff --git a/src/features/bbs/components/MediaDetail.tsx b/src/features/bbs/components/MediaDetail.tsx index f836cd4..ebe12da 100644 --- a/src/features/bbs/components/MediaDetail.tsx +++ b/src/features/bbs/components/MediaDetail.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState, type FormEvent } from "react"; +import { useEffect, useRef, useState, type FormEvent, type TouchEvent } from "react"; import { API_URL, deleteMediaPost, fetchMediaPost, updateMediaPost } from "../api"; import type { MediaPost } from "../types"; import { bar, STATUS } from "./MediaList"; @@ -16,6 +16,38 @@ const formatSize = (bytes: number) => { return `${i === 0 ? n : n.toFixed(1)}${units[i]}`; }; +/** 모바일 더블 탭: 화면 왼쪽 절반 = 5초 뒤로, 오른쪽 절반 = 5초 앞으로 (아래쪽 재생 버튼 줄은 제외) */ +const seekOnDoubleTap = (e: TouchEvent) => { + const v = e.currentTarget; + const touch = e.changedTouches[0]; + const rect = v.getBoundingClientRect(); + if (touch.clientY > rect.bottom - 60) return; // 컨트롤 바 연타는 무시 + const last = Number(v.dataset.lastTap ?? 0); + v.dataset.lastTap = String(e.timeStamp); + if (e.timeStamp - last > 300) return; // 첫 번째 탭 + e.preventDefault(); // 브라우저 기본 더블 탭 동작(확대·전체화면 등) 막기 + v.dataset.lastTap = "0"; // 세 번 연타가 두 번 넘기지 않게 + v.currentTime = Math.max(0, v.currentTime + (touch.clientX - rect.left < rect.width / 2 ? -5 : 5)); +}; + +/** 영상 + 오른쪽 위 2배속 버튼 (누를 때마다 1x ↔ 2x). 전체화면에서는 버튼이 안 보임 → 브라우저 ⋮ 메뉴 사용 */ +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); + }; + return ( +
+
+ ); +}; + /** 자료실 글 보기: 파일마다