Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions e2e/video-controls.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,15 @@ test("进度条悬停显示当前位置缩略图,移开消失", async ({ page
const thumb = page.locator('[data-testid="video-thumb"]');
await expect(thumb).toHaveCount(1);
const tb = (await thumb.boundingBox())!;
// 缩略图底边紧贴进度条上侧(锚定进度条实际 Y,非写死偏移)
const gap = box.y - (tb.y + tb.height);
// 缩略图底边紧贴可见进度轨道上侧(锚定轨道实际 Y,非写死偏移)。
// #1953:基准从 .art-progress 外壳改为 .art-control-progress-inner——外壳顶
// 比轨道顶高 ~11.5px,按外壳量会把悬空误判为贴合。
const trackBox = await page
.locator(".art-control-progress-inner")
.first()
.boundingBox();
if (!trackBox) throw new Error("可见进度轨道不可测量");
const gap = trackBox.y - (tb.y + tb.height);
expect(gap).toBeGreaterThanOrEqual(0);
expect(gap).toBeLessThanOrEqual(12);
// 缩略图显示时,Artplayer 自带的时间气泡隐藏——同屏只留一个时间来源(#1953)
Expand All @@ -287,6 +294,29 @@ test("进度条悬停显示当前位置缩略图,移开消失", async ({ page
await expect(page.locator('[data-testid="video-thumb"]')).toHaveCount(0);
});

test("缩略图底边贴近可见进度轨道(#1953 复测)", async ({ page }) => {
await openMedia(page, "/Users/test/clip.mp4");
await withRealVideo(page);
const progress = page.locator(".art-progress").first();
const box = await progress.boundingBox();
if (!box) throw new Error("进度条不可测量");
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
const thumb = page.locator('[data-testid="video-thumb"]');
await expect(thumb).toHaveCount(1);
const tb = (await thumb.boundingBox())!;
// 量可见轨道 .art-control-progress-inner(3px 高),而非 .art-progress 外壳
// (外壳含 10px 上内边距 + 6px 控件行 + 5px 下内边距,轨道居中其中)。
// 旧实现按外壳顶定位 → 缩略图底边悬在可见线上方 ~19.5px,必失败。
const trackBox = await page
.locator(".art-control-progress-inner")
.first()
.boundingBox();
if (!trackBox) throw new Error("可见进度轨道不可测量");
const gap = trackBox.y - (tb.y + tb.height);
expect(gap).toBeGreaterThan(0);
expect(gap).toBeLessThanOrEqual(12);
});

test("全屏态仍有二级菜单", async ({ page }) => {
await openMedia(page, "/Users/test/clip.mp4");
await withRealVideo(page);
Expand Down
12 changes: 10 additions & 2 deletions src/components/Content/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,15 @@ export default function VideoPlayer({
};
const onProgressMove = (e: MouseEvent) => {
if (!progressEl) return;
const rect = progressEl.getBoundingClientRect();
// #1953:量可见轨道而非 .art-progress 外壳。外壳含 10px 上内边距 + 6px 控件行 +
// 5px 下内边距,3px 轨道居中其中——外壳顶比轨道顶高约 11.5px,旧实现按外壳顶
// 定位使缩略图底边悬在可见线上方 ~19.5px(#1962 删时间行前被时间行占位遮掩)。
// 水平方向外壳无内边距,left/width 与轨道一致,故 ratio 与 left 沿用同一 rect。
// +9 = 6.5px 清指示圆点(16px 圆点上探轨道顶 6.5px)+ 2.5px 余量。
const trackEl =
progressEl.querySelector<HTMLElement>(".art-control-progress-inner") ??
progressEl;
const rect = trackEl.getBoundingClientRect();
const cr = (rootRef.current ?? container).getBoundingClientRect();
const ratio = Math.min(
1,
Expand All @@ -1439,7 +1447,7 @@ export default function VideoPlayer({
const t = ratio * (art.duration || 0);
setThumb({
left: rect.left - cr.left + ratio * rect.width,
bottom: cr.bottom - rect.top + 8,
bottom: cr.bottom - rect.top + 9,
t,
});
if (Date.now() - lastThumbAt < 120) return;
Expand Down
Loading