diff --git a/frontend/src/b/Shorts.tsx b/frontend/src/b/Shorts.tsx index 8281394..a383554 100644 --- a/frontend/src/b/Shorts.tsx +++ b/frontend/src/b/Shorts.tsx @@ -37,6 +37,11 @@ function useTabBarHeight() { const YT_ORIGIN = 'https://www.youtube-nocookie.com' +// 토스 웹뷰에는 플레이어가 보내는 재생 상태가 오지 않는다. 그래서 토스는 첫 장면이 나왔는지를 시간으로 보고 표지를 걷는다 (나머지는 웹과 같다) +const PLAIN = IS_TOSS +// 토스는 재생 상태가 안 오므로, 플레이어 문서가 뜨고 이만큼 지나면 첫 장면이 나왔다고 보고 표지를 걷는다 (그 전엔 플레이어의 검은 화면 대신 표지) +const PLAIN_SHOW_MS = 1000 + function embed(id: string) { const q = new URLSearchParams({ autoplay: '1', mute: '1', playsinline: '1', loop: '1', playlist: id, controls: '0', rel: '0', modestbranding: '1', @@ -147,6 +152,13 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta const tabH = useTabBarHeight() // 첫 장면을 받은 플레이어. 그 전엔 플레이어의 검은 화면 대신 표지를 보인다 const [ready, setReady] = useState>(new Set()) + // 토스: 표지를 걷은 플레이어들. 다음 영상도 미리 띄워 두므로 여럿 + const [plainShown, setPlainShown] = useState>(new Set()) + const plainTimers = useRef(new Set()) + useEffect(() => { + const timers = plainTimers.current + return () => timers.forEach((t) => window.clearTimeout(t)) + }, []) const frames = useRef(new Map()) const atRef = useRef(start) const soundRef = useRef(false) @@ -303,8 +315,8 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta
- {/* 웹은 앞뒤 영상까지 미리 띄워 넘길 때 깜빡이지 않게, 토스 앱은 무거워 지금 영상 하나만 */} - {(IS_TOSS ? i === at : Math.abs(i - at) <= 1) && ( + {/* 릴스처럼 앞뒤 영상을 소리 없이 미리 받아 둔다 */} + {Math.abs(i - at) <= 1 && (