import { isIOS, isSafari, resizeImage } from '@/web/utils/common' import Image from '@/web/components/New/Image' import { cx, css } from '@emotion/css' import useAppleMusicArtist from '@/web/hooks/useAppleMusicArtist' import { useEffect, useRef } from 'react' import Hls from 'hls.js' import { motion } from 'framer-motion' import uiStates from '@/web/states/uiStates' const VideoCover = ({ source }: { source?: string }) => { const ref = useRef(null) const hls = useRef(new Hls()) useEffect(() => { if (source && Hls.isSupported()) { const video = document.querySelector('#video-cover') as HTMLVideoElement hls.current.loadSource(source) hls.current.attachMedia(video) } }, [source]) return (
) } const Cover = ({ artist }: { artist?: Artist }) => { const { data: artistFromApple, isLoading: isLoadingArtistFromApple } = useAppleMusicArtist({ id: artist?.id, name: artist?.name, }) const video = artistFromApple?.attributes?.editorialVideo?.motionArtistSquare1x1?.video const cover = isLoadingArtistFromApple ? '' : artistFromApple?.attributes?.artwork?.url || artist?.img1v1Url useEffect(() => { if (cover) uiStates.blurBackgroundImage = cover }, [cover]) return ( <>
{video && ( {isSafari ? ( ) : ( )} )}
) } export default Cover