"use client"; import { useEffect, useRef } from "react"; import { Anchor, Center, Group, Stack, Title } from "@mantine/core"; import { IconBrandYoutube, IconDeviceCctvOff } from "@tabler/icons-react"; import combineClasses from "clsx"; import videojs from "video.js"; import { useI18n } from "@homarr/translation/client"; import type { WidgetComponentProps } from "../definition"; import classes from "./component.module.css"; import "video.js/dist/video-js.css"; export default function VideoWidget({ options }: WidgetComponentProps<"video">) { if (options.feedUrl.trim() === "") { return ; } if (options.feedUrl.trim().startsWith("https://www.youtube.com/watch")) { return ; } return ; } const NoUrl = () => { const t = useI18n(); return (
{t("widget.video.error.noUrl")}
); }; const ForYoutubeUseIframe = () => { const t = useI18n(); return (
{t("widget.video.error.forYoutubeUseIframe")} {t("common.action.checkoutDocs")}
); }; const Feed = ({ options }: Pick, "options">) => { const videoRef = useRef(null); useEffect(() => { if (!videoRef.current) { return; } // Initialize Video.js player if it's not already initialized if (!("player" in videoRef.current)) { videojs( videoRef.current, { autoplay: options.hasAutoPlay, muted: options.isMuted, controls: options.hasControls, }, () => undefined, ); } }, [videoRef]); return ( ); };