@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 27 lines 671 Bytes
Raw
1 export function prepareVideoFirstFrame(
2 video: Pick<
3 HTMLVideoElement,
4 "autoplay" | "currentTime" | "duration" | "paused" | "played" | "seeking" | "src"
5 >,
6 ): void {
7 if (
8 video.autoplay ||
9 !video.paused ||
10 video.seeking ||
11 video.currentTime !== 0 ||
12 video.played.length > 0 ||
13 !Number.isFinite(video.duration) ||
14 video.duration <= 0
15 ) {
16 return;
17 }
18
19 const fragment = video.src.split("#", 2)[1];
20 if (fragment && new URLSearchParams(fragment).has("t")) return;
21
22 try {
23 video.currentTime = Math.min(0.1, video.duration / 2);
24 } catch {
25 // A rejected preview seek must leave the native Play control usable.
26 }
27 }