fix video not show and make homepage loading scene
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
55bc87bf44
commit
67d9c6f1d9
3 changed files with 24 additions and 14 deletions
|
@ -1,21 +1,24 @@
|
|||
import { useState, useEffect } from 'react';
|
||||
import '../../css/global.css';
|
||||
|
||||
function LoadingScene() {
|
||||
return (
|
||||
<div style={{
|
||||
position: 'fixed',
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: '100vw',
|
||||
height: '100vh',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
height: '100vh',
|
||||
maxWidth:"100vw",
|
||||
fontSize: '24px',
|
||||
color: 'white',
|
||||
backgroundColor: 'black'
|
||||
backgroundColor: 'black',
|
||||
zIndex: 9999 // Ensures it's on top of everything
|
||||
}}>
|
||||
Loading...
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default LoadingScene
|
||||
export default LoadingScene;
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import { useEffect } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import '../css/global.css';
|
||||
import BlackButton from './components/customButton';
|
||||
import LoadingScene from './components/loadingScene';
|
||||
|
||||
function HomePage() {
|
||||
const [loading, setLoading] = useState(true); // Track loading state
|
||||
|
||||
useEffect(() => {
|
||||
const controller = new AbortController();
|
||||
|
||||
|
@ -10,16 +13,17 @@ function HomePage() {
|
|||
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
|
||||
cache: 'force-cache',
|
||||
});
|
||||
|
||||
// Read the response into memory (helps trigger caching)
|
||||
await res.blob();
|
||||
await res.blob(); // Read into memory to trigger caching
|
||||
console.log('Video prefetched successfully.');
|
||||
} catch (err) {
|
||||
if (err.name !== 'AbortError') {
|
||||
console.error('Video prefetch failed:', err);
|
||||
}
|
||||
} finally {
|
||||
setLoading(false); // Done loading either way
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -28,6 +32,12 @@ function HomePage() {
|
|||
return () => controller.abort();
|
||||
}, []);
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<LoadingScene/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
|
|
|
@ -51,13 +51,10 @@ function IntroductionPage() {
|
|||
{loading ? (
|
||||
<LoadingScene />
|
||||
) : (
|
||||
<div>
|
||||
<IntroductionPageData />
|
||||
<PlayVideo onVideoReady={handleVideoReady} />
|
||||
</div>
|
||||
|
||||
)}
|
||||
|
||||
<PlayVideo onVideoReady={handleVideoReady} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue