create loading scene
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
NekoVari 2025-04-18 04:34:55 +07:00
parent 674ce7f6d6
commit b9ac141e29
3 changed files with 58 additions and 31 deletions

View file

@ -0,0 +1,20 @@
import { useState, useEffect } from 'react';
import '../../css/global.css';
function LoadingScene() {
return (
<div style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: '100vh',
fontSize: '24px',
color: 'white',
backgroundColor: 'black'
}}>
Loading...
</div>
);
}
export default LoadingScene

View file

@ -1,9 +1,9 @@
import '../../css/video.css' import '../../css/video.css';
function PlayVideo({ src="hallway_FFF.mp4" }) { function PlayVideo({ src = "hallway_FFF.mp4", onVideoReady }) {
const urlSource = `${import.meta.env.VITE_ASSETS_URL}/${src}`; const urlSource = `${import.meta.env.VITE_ASSETS_URL}/${src}`;
return( return (
<div className="video-container"> <div className="video-container">
<video <video
autoPlay autoPlay
@ -12,16 +12,19 @@ function PlayVideo({ src="hallway_FFF.mp4" }) {
playsInline playsInline
loop loop
pointerEvents="none" pointerEvents="none"
onLoadedData={(e) => { onCanPlayThrough={(e) => {
e.target.play() e.target.play();
console.log("played"); console.log("Video is ready and played");
if (onVideoReady) {
onVideoReady(); // Call the callback to notify that the video is ready
}
}} }}
> >
<source src={urlSource} type="video/mp4"/> <source src={urlSource} type="video/mp4" />
Your browser does not support the video tag. Your browser does not support the video tag.
</video> </video>
</div> </div>
) );
} }
export default PlayVideo export default PlayVideo;

View file

@ -3,9 +3,10 @@ import '../css/global.css'
import BlackButton from './components/customButton' import BlackButton from './components/customButton'
import Animation from './components/animation.jsx'; import Animation from './components/animation.jsx';
import PlayVideo from './components/playVideo.jsx'; import PlayVideo from './components/playVideo.jsx';
import LoadingScene from './components/loadingScene.jsx';
function IntroductionPage() { function IntroductionPageData(){
return( return(
<div style={{ <div style={{
display: 'flex', display: 'flex',
justifyContent: 'center', justifyContent: 'center',
@ -14,25 +15,7 @@ function IntroductionPage() {
maxWidth:"100vw", maxWidth:"100vw",
flexDirection: 'column', flexDirection: 'column',
}}> }}>
{/* <div style={{position:"absolute"}}> {/* <PlayVideo src='hallway_FFF.mp4'/> */}
<Animation src='6_Classroom.zip' animationWidth='100vw'/>
</div>
<div style={{position:"absolute"}}>
<Animation src='5_M_Pie.zip' animationWidth='100vw'/>
</div>
<div style={{position:"absolute"}}>
<Animation src='4_NPC+hallway.zip' animationWidth='100vw'/>
</div>
<div style={{position:"absolute"}}>
<Animation src='3_M_Patt.zip' animationWidth='100vw'/>
</div>
<div style={{position:"absolute"}}>
<Animation src='2_M_Porsche.zip' animationWidth='100vw'/>
</div>
<div style={{position:"absolute"}}>
<Animation src='1_NPC+pillar.zip' animationWidth='100vw'/>
</div> */}
<PlayVideo src='hallway_FFF.mp4'/>
<div style={{ <div style={{
position: "fixed", position: "fixed",
@ -57,4 +40,25 @@ function IntroductionPage() {
) )
} }
function IntroductionPage() {
const [loading, setLoading] = useState(true);
const handleVideoReady = () => {
setLoading(false); // Set loading to false when the video is ready
};
return (
<div>
{loading ? (
<LoadingScene />
) : (
<IntroductionPageData />
)}
<PlayVideo onVideoReady={handleVideoReady} />
</div>
);
}
export default IntroductionPage export default IntroductionPage