diff --git a/client/src/components/VimeoEmbed.tsx b/client/src/components/VimeoEmbed.tsx index 450f93e..2860688 100644 --- a/client/src/components/VimeoEmbed.tsx +++ b/client/src/components/VimeoEmbed.tsx @@ -14,14 +14,16 @@ declare global { Player: new ( el: HTMLIFrameElement | HTMLElement, opts?: { id?: string | number; url?: string } - ) => { - on: (event: string, cb: (data?: unknown) => void) => void; - destroy: () => void; - }; + ) => VimeoPlayerInstance; }; } } +type VimeoPlayerInstance = { + on: (event: string, cb: (data?: unknown) => void) => void; + destroy: () => void; +}; + let playerSdkPromise: Promise | null = null; function loadVimeoSdk(): Promise { @@ -57,7 +59,7 @@ export function VimeoEmbed({ videoId, title, watchUrl, poster }: Props) { const embedSrc = `https://player.vimeo.com/video/${videoId}?title=0&byline=0&portrait=0`; useEffect(() => { - let player: { destroy: () => void } | null = null; + let player: VimeoPlayerInstance | null = null; let cancelled = false; setBlocked(false); @@ -66,7 +68,7 @@ export function VimeoEmbed({ videoId, title, watchUrl, poster }: Props) { .then(() => { if (cancelled || !iframeRef.current || !window.Vimeo?.Player) return; player = new window.Vimeo.Player(iframeRef.current); - player.on("error", (data: unknown) => { + player.on("error", (data?: unknown) => { // Privacy / password / unavailable — leave site only as last resort console.warn("Vimeo player error", data); if (!cancelled) setBlocked(true);