import { css, cx } from '@emotion/css' import { createPortal } from 'react-dom' import useMV, { useMVUrl } from '../../api/hooks/useMV' import { AnimatePresence, motion } from 'framer-motion' import { ease } from '@/web/utils/const' import Icon from '../Icon' import VideoInstance from './VideoInstance' import { toHttps } from '@/web/utils/common' import uiStates, { closeVideoPlayer } from '@/web/states/uiStates' import { useSnapshot } from 'valtio' import { useNavigate } from 'react-router-dom' const VideoPlayer = () => { const { playingVideoID } = useSnapshot(uiStates) const { fullscreen } = useSnapshot(uiStates) const navigate = useNavigate() const { data: mv, isLoading } = useMV({ mvid: playingVideoID || 0 }) const { data: mvDetails } = useMVUrl({ id: playingVideoID || 0 }) const mvUrl = toHttps(mvDetails?.data?.url) const poster = toHttps(mv?.data.cover) return createPortal( {playingVideoID && (
{/* Blur bg */} {/* Video Title */}
{isLoading ? ( PLACEHOLDER2023 ) : ( <>
{ if (!mv?.data.artistId) return closeVideoPlayer() navigate('/artist/' + mv.data.artistId) }} className='transition duration-400 hover:underline' > {mv?.data.artistName} {' '} - {mv?.data.name}
{mv?.data.publishTime.slice(0, 4)}
)}
{/* Video */} {/* Close button */}
{ const video = document.querySelector('#video-player video') as HTMLVideoElement video?.pause() closeVideoPlayer() }} className='flex h-14 w-14 items-center justify-center rounded-full bg-white/10 text-white/50 transition-colors duration-300 hover:bg-white/20 hover:text-white/70' >
)}
, document.body ) } export default VideoPlayer