From 130f14e96a1116575a4429f2fe83f339fc49d341 Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Mon, 26 Oct 2026 16:41:15 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=86=A0=EC=8A=A4=ED=8C=90=20=EC=87=BC?= =?UTF-8?q?=EC=B8=A0=EB=A5=BC=20=EC=97=B4=EA=B1=B0=EB=82=98=20=EB=84=98?= =?UTF-8?q?=EA=B8=B8=20=EB=95=8C=20=EA=B2=80=EC=9D=80=20=ED=94=8C=EB=A0=88?= =?UTF-8?q?=EC=9D=B4=EC=96=B4=EA=B0=80=20=EA=B9=9C=EB=B9=A1=EC=9E=84=20?= =?UTF-8?q?=E2=80=94=20=EC=9E=AC=EC=83=9D=20=EC=83=81=ED=83=9C=EA=B0=80=20?= =?UTF-8?q?=EC=95=88=20=EC=98=A4=EB=AF=80=EB=A1=9C=20=ED=94=8C=EB=A0=88?= =?UTF-8?q?=EC=9D=B4=EC=96=B4=20=EB=AC=B8=EC=84=9C=EA=B0=80=20=EB=9C=A8?= =?UTF-8?q?=EA=B3=A0=201=EC=B4=88=20=EB=92=A4=EA=B9=8C=EC=A7=80=20?= =?UTF-8?q?=ED=91=9C=EC=A7=80=EB=A1=9C=20=EA=B0=80=EB=A0=B8=EB=8B=A4?= =?UTF-8?q?=EA=B0=80=20=EC=84=9C=EC=84=9C=ED=9E=88=20=EB=9D=84=EC=9B=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/b/Shorts.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/src/b/Shorts.tsx b/frontend/src/b/Shorts.tsx index bfbf95f..aab80b0 100644 --- a/frontend/src/b/Shorts.tsx +++ b/frontend/src/b/Shorts.tsx @@ -34,6 +34,8 @@ const YT_ORIGIN = 'https://www.youtube-nocookie.com' // 토스 웹뷰에는 플레이어가 보내는 재생 상태가 오지 않아, 쇼츠 페이지는 플레이어를 숨기거나 명령하지 않고 유튜브 기본 조작(재생 버튼)과 소리를 켠 채 그대로 보인다. // 영상 위 터치는 유튜브가 가져가므로 넘기기는 버튼으로 const PLAIN = IS_TOSS +// 토스는 재생 상태가 안 오므로, 플레이어 문서가 뜨고 이만큼 지나면 첫 장면이 나왔다고 보고 표지를 걷는다 (그 전엔 플레이어의 검은 화면 대신 표지) +const PLAIN_SHOW_MS = 1000 function embed(id: string, plain = false) { const q = new URLSearchParams({ @@ -144,6 +146,10 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta const tabH = useTabBarHeight() // 첫 장면을 받은 플레이어. 그 전엔 플레이어의 검은 화면 대신 표지를 보인다 const [ready, setReady] = useState>(new Set()) + // 토스: 표지를 걷은 플레이어 번호 (하나만 띄우므로 하나) + const [plainShownAt, setPlainShownAt] = useState(-1) + const plainTimer = useRef(0) + useEffect(() => () => window.clearTimeout(plainTimer.current), []) const frames = useRef(new Map()) const atRef = useRef(start) const soundRef = useRef(false) @@ -327,6 +333,10 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta allow="autoplay; encrypted-media; picture-in-picture" // 재생 상태를 받으려면 플레이어에 먼저 '듣고 있다'고 알린다 onLoad={(e) => { + if (PLAIN) { + window.clearTimeout(plainTimer.current) + plainTimer.current = window.setTimeout(() => setPlainShownAt(i), PLAIN_SHOW_MS) + } e.currentTarget.contentWindow?.postMessage(JSON.stringify({ event: 'listening', id: s.id }), YT_ORIGIN) // 앞뒤 밖으로 밀려나 내려갔다 다시 뜬 플레이어는 첫 장면을 새로 받을 때까지 다시 숨긴다 setReady((r) => { @@ -336,7 +346,7 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta return next }) }} - className={cx('absolute inset-0 size-full border-0 transition-opacity duration-200', !PLAIN && !ready.has(i) && 'opacity-0')} + className={cx('absolute inset-0 size-full border-0 transition-opacity duration-200', (PLAIN ? plainShownAt !== i : !ready.has(i)) && 'opacity-0')} /> )} {!PLAIN && (