From 9adee6762e4cef1612d35e08c8a5eaff60ba1b9f Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Mon, 26 Oct 2026 14:40:10 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=87=BC=EC=B8=A0=20=EC=B0=BD=EC=9D=84?= =?UTF-8?q?=20=EC=B2=98=EC=9D=8C=20=EC=97=B4=20=EB=95=8C=20=EA=B2=80?= =?UTF-8?q?=EC=9D=80=20=ED=94=8C=EB=A0=88=EC=9D=B4=EC=96=B4=EA=B0=80=20?= =?UTF-8?q?=EA=B9=9C=EB=B9=A1=EC=9D=B4=EB=8D=98=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=E2=80=94=20=EC=B2=AB=20=EC=9E=A5=EB=A9=B4=EC=9D=B4=20=EC=9E=AC?= =?UTF-8?q?=EC=83=9D=EB=90=A0=20=EB=95=8C=EA=B9=8C=EC=A7=80=20=ED=91=9C?= =?UTF-8?q?=EC=A7=80=EB=A5=BC=20=EB=B3=B4=EC=9D=B4=EA=B3=A0=20=ED=94=8C?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EC=96=B4=EB=8A=94=20=EA=B7=B8=20=EB=92=A4?= =?UTF-8?q?=EC=97=90=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 | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/frontend/src/b/Shorts.tsx b/frontend/src/b/Shorts.tsx index d116d03..9e7e9f4 100644 --- a/frontend/src/b/Shorts.tsx +++ b/frontend/src/b/Shorts.tsx @@ -102,13 +102,15 @@ function ShortCard({ s, playing, onOpen }: { s: ShortItem; playing: boolean; onO /** * 전체 화면 재생 창: 네이티브 라 ESC·포커스 가두기가 기본. - * 넘길 때 검은 화면이 보이지 않게 앞뒤 영상도 소리 없이 틀어 첫 장면을 받아 둔 뒤 멈춰 두고, 보이는 것만 처음부터 재생한다 + * 처음 열 때·넘길 때 검은 화면이 보이지 않게, 첫 장면을 받을 때까지는 표지를 보이고 앞뒤 영상도 소리 없이 틀어 첫 장면을 받아 둔 뒤 멈춰 두고, 보이는 것만 처음부터 재생한다 */ function ShortsViewer({ items, start, onClose }: { items: ShortItem[]; start: number; onClose: () => void }) { const dialog = useRef(null) const list = useRef(null) const [at, setAt] = useState(start) const [sound, setSound] = useState(false) + // 첫 장면을 받은 플레이어. 그 전엔 플레이어의 검은 화면 대신 표지를 보인다 + const [ready, setReady] = useState>(new Set()) const frames = useRef(new Map()) const atRef = useRef(start) const soundRef = useRef(false) @@ -151,7 +153,9 @@ function ShortsViewer({ items, start, onClose }: { items: ShortItem[]; start: nu } if (msg.info?.playerState !== PLAYING) return for (const [i, f] of frames.current) { - if (f.contentWindow !== e.source || i === atRef.current) continue + if (f.contentWindow !== e.source) continue + setReady((r) => (r.has(i) ? r : new Set(r).add(i))) + if (i === atRef.current) continue command(f, 'pauseVideo') command(f, 'seekTo', [0, true]) } @@ -205,8 +209,17 @@ function ShortsViewer({ items, start, onClose }: { items: ShortItem[]; start: nu title={s.title} allow="autoplay; encrypted-media; picture-in-picture" // 재생 상태를 받으려면 플레이어에 먼저 '듣고 있다'고 알린다 - onLoad={(e) => e.currentTarget.contentWindow?.postMessage(JSON.stringify({ event: 'listening', id: s.id }), YT_ORIGIN)} - className="absolute inset-0 size-full border-0" + onLoad={(e) => { + e.currentTarget.contentWindow?.postMessage(JSON.stringify({ event: 'listening', id: s.id }), YT_ORIGIN) + // 앞뒤 밖으로 밀려나 내려갔다 다시 뜬 플레이어는 첫 장면을 새로 받을 때까지 다시 숨긴다 + setReady((r) => { + if (!r.has(i)) return r + const next = new Set(r) + next.delete(i) + return next + }) + }} + className={cx('absolute inset-0 size-full border-0 transition-opacity duration-200', !ready.has(i) && 'opacity-0')} /> )}