"use client" import { useEffect, useState, useTransition } from "react" import { RiCheckboxCircleFill } from "react-icons/ri" import { PiShareFatLight } from "react-icons/pi" import CopyToClipboard from "react-copy-to-clipboard" import { LuCopyCheck } from "react-icons/lu" import { LuScrollText } from "react-icons/lu" import { BiCameraMovie } from "react-icons/bi" import { useStore } from "@/app/state/useStore" import { cn } from "@/lib/utils" import { VideoPlayer } from "@/app/interface/video-player" import { VideoInfo } from "@/types" import { ActionButton, actionButtonClassName } from "@/app/interface/action-button" import { RecommendedVideos } from "@/app/interface/recommended-videos" import { isCertifiedUser } from "@/app/certification" import { watchVideo } from "@/app/server/actions/stats" import { formatTimeAgo } from "@/lib/formatTimeAgo" import { DefaultAvatar } from "@/app/interface/default-avatar" export function PublicVideoView() { const [_pending, startTransition] = useTransition() const video = useStore(s => s.publicVideo) const videoId = `${video?.id || ""}` const [copied, setCopied] = useState(false) const [channelThumbnail, setChannelThumbnail] = useState(`${video?.channel.thumbnail || ""}`) const setPublicVideo = useStore(s => s.setPublicVideo) // we inject the current videoId in the URL, if it's not already present // this is a hack for Hugging Face iframes useEffect(() => { const queryString = new URL(location.href).search const searchParams = new URLSearchParams(queryString) if (videoId) { if (searchParams.get("v") !== videoId) { console.log(`current videoId "${videoId}" isn't set in the URL query params.. TODO we should set it`) // searchParams.set("v", videoId) // location.search = searchParams.toString() } } else { // searchParams.delete("v") // location.search = searchParams.toString() } }, [videoId]) useEffect(() => { if (copied) { setTimeout(() => { setCopied(false) }, 2000) } }, [copied]) const handleBadChannelThumbnail = () => { try { if (channelThumbnail) { setChannelThumbnail("") } } catch (err) { } } useEffect(() => { startTransition(async () => { if (!video || !video.id) { return } const numberOfViews = await watchVideo(videoId) setPublicVideo({ ...video, numberOfViews }) }) }, [video?.id]) if (!video) { return null } return (
{/** VIDEO PLAYER - HORIZONTAL */} {/** VIDEO TITLE - HORIZONTAL */}
{video.label}
{/*
AI Video Model: {video.model || "HotshotXL"}
*/}
{/** VIDEO TOOLBAR - HORIZONTAL */}
{/** LEFT PART OF THE TOOLBAR */} {/** RIGHT PART OF THE TOOLBAR */}
{/* SHARE */}
setCopied(true)}>
{ copied ? : }
{ copied ? "Link copied!" : "Share video" }
Made with {video.model} See prompt
{/** VIDEO DESCRIPTION - VERTICAL */}
{video.numberOfViews} views
{formatTimeAgo(video.updatedAt).replace("about ", "")}

{video.description}

) }