preload in homepage
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
9bf674edf5
commit
4744ee5909
2 changed files with 40 additions and 18 deletions
|
@ -1,25 +1,48 @@
|
||||||
import { useState } from 'react'
|
import { useEffect } from 'react';
|
||||||
import '../css/global.css'
|
import '../css/global.css';
|
||||||
import BlackButton from './components/customButton'
|
import BlackButton from './components/customButton';
|
||||||
|
|
||||||
function HomePage() {
|
function HomePage() {
|
||||||
|
useEffect(() => {
|
||||||
|
const controller = new AbortController();
|
||||||
|
|
||||||
|
const fetchVideo = async () => {
|
||||||
|
try {
|
||||||
|
const res = await fetch(`${import.meta.env.VITE_ASSETS_URL}/hallway_FFF.mp4`, {
|
||||||
|
signal: controller.signal,
|
||||||
|
cache: 'force-cache', // Helps to ensure the response is stored
|
||||||
|
});
|
||||||
|
|
||||||
return(
|
// Read the response into memory (helps trigger caching)
|
||||||
<div style={{
|
await res.blob();
|
||||||
display: 'flex',
|
console.log('Video prefetched successfully.');
|
||||||
justifyContent: 'center',
|
} catch (err) {
|
||||||
alignItems: 'center',
|
if (err.name !== 'AbortError') {
|
||||||
height: '100vh',
|
console.error('Video prefetch failed:', err);
|
||||||
flexDirection: 'column',
|
}
|
||||||
}}>
|
}
|
||||||
<label className='title'>Fifty Shades <br /> of Bully</label>
|
};
|
||||||
|
|
||||||
<div style={{ height: '8vh' }}/>
|
fetchVideo();
|
||||||
|
|
||||||
<BlackButton text="Start" to='/warn'/>
|
return () => controller.abort();
|
||||||
</div>
|
}, []);
|
||||||
)
|
|
||||||
|
return (
|
||||||
|
<div style={{
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
height: '100vh',
|
||||||
|
flexDirection: 'column',
|
||||||
|
}}>
|
||||||
|
<label className='title'>Fifty Shades <br /> of Bully</label>
|
||||||
|
|
||||||
|
<div style={{ height: '8vh' }} />
|
||||||
|
|
||||||
|
<BlackButton text="Start" to='/warn' />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default HomePage
|
export default HomePage;
|
||||||
|
|
|
@ -15,7 +15,6 @@ function IntroductionPageData(){
|
||||||
maxWidth:"100vw",
|
maxWidth:"100vw",
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
}}>
|
}}>
|
||||||
{/* <PlayVideo src='hallway_FFF.mp4'/> */}
|
|
||||||
|
|
||||||
<div style={{
|
<div style={{
|
||||||
position: "fixed",
|
position: "fixed",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue