fifty-shades-of-bully/src/pages/homePage.jsx

59 lines
1.4 KiB
React
Raw Normal View History

import { useEffect, useState } from 'react';
2025-04-18 07:53:47 +07:00
import '../css/global.css';
import BlackButton from './components/customButton';
import LoadingScene from './components/loadingScene';
2024-11-29 01:14:25 +07:00
function HomePage() {
const [loading, setLoading] = useState(true); // Track loading state
2025-04-18 07:53:47 +07:00
useEffect(() => {
const controller = new AbortController();
2024-11-29 01:14:25 +07:00
2025-04-18 07:53:47 +07:00
const fetchVideo = async () => {
try {
const res = await fetch(`${import.meta.env.VITE_ASSETS_URL}/hallway_FFF.mp4`, {
signal: controller.signal,
cache: 'force-cache',
2025-04-18 07:53:47 +07:00
});
2024-11-29 01:14:25 +07:00
await res.blob(); // Read into memory to trigger caching
2025-04-18 07:53:47 +07:00
console.log('Video prefetched successfully.');
} catch (err) {
if (err.name !== 'AbortError') {
console.error('Video prefetch failed:', err);
}
} finally {
setLoading(false); // Done loading either way
2025-04-18 07:53:47 +07:00
}
};
2025-04-18 07:53:47 +07:00
fetchVideo();
2025-04-18 07:53:47 +07:00
return () => controller.abort();
}, []);
if (loading) {
return (
<LoadingScene/>
);
}
2025-04-18 07:53:47 +07:00
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>
);
2024-11-29 01:14:25 +07:00
}
2025-04-18 07:53:47 +07:00
export default HomePage;