"use client"; import { IYoutubeItem } from "@/interfaces/youtube"; import Image from "next/image"; import { useState } from "react"; export default function YouTubeEmbed({ video, width = 424, height = 238, loadIframe = false, autoPlay = true, }: { video: IYoutubeItem | string; width?: number | "full"; height?: number | "full"; loadIframe?: boolean; autoPlay?: boolean; }) { const [isIframeLoaded, setIframeLoaded] = useState(loadIframe); const id = typeof video === "string" ? video : typeof video.id === "string" ? video.snippet.resourceId.videoId : video.id.videoId; const isString = typeof video === "string"; const _loadIframe = () => setIframeLoaded(true); return (
{isIframeLoaded ? (