feat: add video background support (#1839)
This commit is contained in:
@@ -243,6 +243,12 @@ const BackgroundImage = () => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the background image URL is a video
|
||||||
|
const videoFormat = getVideoFormat(config?.settings.customization.backgroundImageUrl);
|
||||||
|
if (videoFormat) {
|
||||||
|
return <BackgroundVideo videoSource={config?.settings.customization.backgroundImageUrl} videoFormat={videoFormat} />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Global
|
<Global
|
||||||
styles={{
|
styles={{
|
||||||
@@ -259,6 +265,41 @@ const BackgroundImage = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const getVideoFormat = (video: string) => {
|
||||||
|
const supportedFormats = ['mp4', 'webm', 'ogg'];
|
||||||
|
for(const format of supportedFormats) {
|
||||||
|
if(video.endsWith(format)) return format;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface BackgroundVideoProps {
|
||||||
|
videoSource: string;
|
||||||
|
videoFormat: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BackgroundVideo = ({videoSource, videoFormat}: BackgroundVideoProps) => {
|
||||||
|
return (
|
||||||
|
<video
|
||||||
|
autoPlay
|
||||||
|
muted
|
||||||
|
loop
|
||||||
|
style={{
|
||||||
|
position: 'fixed',
|
||||||
|
width: '100vw',
|
||||||
|
height: '100vh',
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
objectFit: 'cover'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<source src={videoSource} type={`video/${videoFormat}`} />
|
||||||
|
</video>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
export const useBoardLink = (
|
export const useBoardLink = (
|
||||||
link: '/board' | `/board/${string}/customize` | `/board/${string}`
|
link: '/board' | `/board/${string}/customize` | `/board/${string}`
|
||||||
) => {
|
) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user