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';
|
import '../../css/global.css';
|
||||||
|
|
||||||
function LoadingScene() {
|
function LoadingScene() {
|
||||||
return (
|
return (
|
||||||
<div style={{
|
<div style={{
|
||||||
|
position: 'fixed',
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
width: '100vw',
|
||||||
|
height: '100vh',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
height: '100vh',
|
|
||||||
maxWidth:"100vw",
|
|
||||||
fontSize: '24px',
|
fontSize: '24px',
|
||||||
color: 'white',
|
color: 'white',
|
||||||
backgroundColor: 'black'
|
backgroundColor: 'black',
|
||||||
|
zIndex: 9999 // Ensures it's on top of everything
|
||||||
}}>
|
}}>
|
||||||
Loading...
|
Loading...
|
||||||
</div>
|
</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 '../css/global.css';
|
||||||
import BlackButton from './components/customButton';
|
import BlackButton from './components/customButton';
|
||||||
|
import LoadingScene from './components/loadingScene';
|
||||||
|
|
||||||
function HomePage() {
|
function HomePage() {
|
||||||
|
const [loading, setLoading] = useState(true); // Track loading state
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
|
|
||||||
|
@ -10,16 +13,17 @@ function HomePage() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${import.meta.env.VITE_ASSETS_URL}/hallway_FFF.mp4`, {
|
const res = await fetch(`${import.meta.env.VITE_ASSETS_URL}/hallway_FFF.mp4`, {
|
||||||
signal: controller.signal,
|
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(); // Read into memory to trigger caching
|
||||||
await res.blob();
|
|
||||||
console.log('Video prefetched successfully.');
|
console.log('Video prefetched successfully.');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.name !== 'AbortError') {
|
if (err.name !== 'AbortError') {
|
||||||
console.error('Video prefetch failed:', err);
|
console.error('Video prefetch failed:', err);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
setLoading(false); // Done loading either way
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -28,6 +32,12 @@ function HomePage() {
|
||||||
return () => controller.abort();
|
return () => controller.abort();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return (
|
||||||
|
<LoadingScene/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{
|
<div style={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
|
|
@ -51,13 +51,10 @@ function IntroductionPage() {
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<LoadingScene />
|
<LoadingScene />
|
||||||
) : (
|
) : (
|
||||||
<div>
|
<IntroductionPageData />
|
||||||
<IntroductionPageData />
|
|
||||||
<PlayVideo onVideoReady={handleVideoReady} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<PlayVideo onVideoReady={handleVideoReady} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue