feat: 💨
This commit is contained in:
parent
f785d0d8a2
commit
206cbf7e19
5 changed files with 46 additions and 13 deletions
|
|
@ -7,10 +7,12 @@ import { useTranslation } from 'react-i18next'
|
|||
|
||||
export default function YoutubeEmbeddedPlayer({
|
||||
url,
|
||||
className
|
||||
className,
|
||||
mustLoad = false
|
||||
}: {
|
||||
url: string
|
||||
className?: string
|
||||
mustLoad?: boolean
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const { autoLoadMedia } = useContentPolicy()
|
||||
|
|
@ -29,7 +31,7 @@ export default function YoutubeEmbeddedPlayer({
|
|||
}, [autoLoadMedia])
|
||||
|
||||
useEffect(() => {
|
||||
if (!videoId || !containerRef.current || !display) return
|
||||
if (!videoId || !containerRef.current || (!mustLoad && !display)) return
|
||||
|
||||
if (!window.YT) {
|
||||
const script = document.createElement('script')
|
||||
|
|
@ -75,9 +77,9 @@ export default function YoutubeEmbeddedPlayer({
|
|||
playerRef.current.destroy()
|
||||
}
|
||||
}
|
||||
}, [videoId, display])
|
||||
}, [videoId, display, mustLoad])
|
||||
|
||||
if (!display) {
|
||||
if (!mustLoad && !display) {
|
||||
return (
|
||||
<div
|
||||
className="text-primary hover:underline truncate w-fit cursor-pointer"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue