문서: 제한 시간·힌트는 문제 경과 시간(전체 일시정지만 제외)으로, 클립은 재생 위치로 정지 — 클립 단계 +3초 처리 명시. 시험 도구를 위치 기준 정지·클릭 내 소리 허용으로 고쳐 재실행한 결과 반영
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,7 +31,13 @@ const waitState = (want, ms) => new Promise(res => {
|
||||
}, 20);
|
||||
});
|
||||
// gesture unlock: called from the join button click handler
|
||||
document.getElementById('join').onclick = () => { ev('gesture'); window.__gesture = true; };
|
||||
// Unlock inside the click: play the cued video unmuted once, then pause (docs/12 Q1 "소리 허용").
|
||||
document.getElementById('join').onclick = () => {
|
||||
ev('gesture');
|
||||
// load+play unmuted inside the user gesture (window.__unlock = {id, start} set by the page/app)
|
||||
player.unMute(); player.loadVideoById({ videoId: window.__unlock.id, startSeconds: window.__unlock.start });
|
||||
waitState(YT.PlayerState.PLAYING, 5000).then(ok => { ev('unlock', { ok, muted: player.isMuted() }); player.pauseVideo(); });
|
||||
};
|
||||
window.probe = {
|
||||
log, apiReady: () => apiReady,
|
||||
// Prepare: muted load at startSec, wait until really playing, then pause -> ready
|
||||
@@ -45,21 +51,28 @@ window.probe = {
|
||||
player.seekTo(startSec, true);
|
||||
return { ok, ms: Math.round(performance.now() - t0), dur: player.getDuration(), at: player.getCurrentTime() };
|
||||
},
|
||||
// Play unmuted at wall-clock epoch ms `at`, stop after clipMs (0 = keep playing)
|
||||
play(at, clipMs) {
|
||||
setUnlock(id, start) { window.__unlock = { id, start }; },
|
||||
// Play unmuted at wall-clock epoch ms `at`. clipSec > 0: stop by PLAYBACK POSITION
|
||||
// (getCurrentTime() >= startSec + clipSec), checked every animation frame + 10ms timer.
|
||||
play(at, startSec, clipSec) {
|
||||
return new Promise(res => {
|
||||
setTimeout(async () => {
|
||||
const startWall = Date.now();
|
||||
player.unMute(); player.playVideo();
|
||||
const playing = await waitState(YT.PlayerState.PLAYING, 5000);
|
||||
const firstPlayingWall = Date.now();
|
||||
const lateMs = Date.now() - at;
|
||||
const muted = player.isMuted();
|
||||
if (!clipMs) return res({ playing, muted, lateMs: firstPlayingWall - at });
|
||||
setTimeout(() => {
|
||||
const pos = player.getCurrentTime();
|
||||
player.pauseVideo();
|
||||
res({ playing, muted, lateMs: firstPlayingWall - at, startWall, stopPos: pos });
|
||||
}, at + clipMs - Date.now());
|
||||
if (!clipSec) return res({ playing, muted, lateMs });
|
||||
const end = startSec + clipSec;
|
||||
let done = false;
|
||||
const check = () => {
|
||||
if (done) return;
|
||||
if (player.getCurrentTime() >= end) {
|
||||
done = true; clearInterval(iv); player.pauseVideo();
|
||||
setTimeout(() => res({ playing, muted, lateMs, stopPos: player.getCurrentTime(), errSec: player.getCurrentTime() - end }), 300);
|
||||
} else requestAnimationFrame(check);
|
||||
};
|
||||
const iv = setInterval(check, 10);
|
||||
requestAnimationFrame(check);
|
||||
}, Math.max(0, at - Date.now()));
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Real-browser probe of the hidden YouTube IFrame playback design (docs/12-decisions.md Q1).
|
||||
// Usage: bun tools/prototypes/iframe-sync/run.ts (needs playwright-core + /usr/bin/google-chrome)
|
||||
// Checks: autoplay policy with/without a user gesture, prepare (muted preload) time,
|
||||
// synchronized unmuted start across 3 clients, 1-second clip accuracy, drift over 10s.
|
||||
// synchronized unmuted start across 3 clients, 1-second clip stopped by playback position
|
||||
// (errSec = stop position - (start + 1s)), drift over 10s.
|
||||
import { chromium } from "playwright-core";
|
||||
|
||||
const html = await Bun.file(new URL("./player.html", import.meta.url)).text();
|
||||
@@ -19,7 +20,11 @@ async function client(gesture: boolean) {
|
||||
const page = await ctx.newPage();
|
||||
await page.goto(url);
|
||||
await page.evaluate(() => (window as any).probe.apiReady());
|
||||
if (gesture) await page.click("#join");
|
||||
if (gesture) {
|
||||
await page.evaluate(([v, s]) => (window as any).probe.setUnlock(v, s), [VIDEO, START] as const);
|
||||
await page.click("#join");
|
||||
await page.waitForFunction(() => (window as any).probe.log.some((e: any) => e.k === "unlock"), null, { timeout: 15000 });
|
||||
}
|
||||
return page;
|
||||
}
|
||||
const p = (page: any, fn: string, ...a: any[]) => page.evaluate(([fn, a]: any) => (window as any).probe[fn](...a), [fn, a]);
|
||||
@@ -30,7 +35,7 @@ const out: Record<string, unknown> = {};
|
||||
{
|
||||
const page = await client(false);
|
||||
out.noGesture_prepare = await p(page, "prepare", VIDEO, START);
|
||||
out.noGesture_play = await p(page, "play", Date.now() + 300, 1500);
|
||||
out.noGesture_play = await p(page, "play", Date.now() + 300, START, 1);
|
||||
out.noGesture_events = (await page.evaluate(() => (window as any).probe.log)).filter((e: any) => e.k !== "state");
|
||||
await page.context().close();
|
||||
}
|
||||
@@ -40,11 +45,11 @@ const out: Record<string, unknown> = {};
|
||||
const pages = await Promise.all([client(true), client(true), client(true)]);
|
||||
out.prepare = await Promise.all(pages.map(pg => p(pg, "prepare", VIDEO, START)));
|
||||
const at = Date.now() + 800;
|
||||
out.clip1s = await Promise.all(pages.map(pg => p(pg, "play", at, 1000)));
|
||||
out.clip1s = await Promise.all(pages.map(pg => p(pg, "play", at, START, 1)));
|
||||
// drift: re-prepare then play 10s continuously, sample positions at the same wall instants
|
||||
await Promise.all(pages.map(pg => p(pg, "prepare", VIDEO, START)));
|
||||
const at2 = Date.now() + 800;
|
||||
out.longStart = await Promise.all(pages.map(pg => p(pg, "play", at2, 0)));
|
||||
out.longStart = await Promise.all(pages.map(pg => p(pg, "play", at2, START, 0)));
|
||||
const samples: number[][] = [];
|
||||
for (let i = 0; i < 5; i++) {
|
||||
await Bun.sleep(2000);
|
||||
|
||||
Reference in New Issue
Block a user