fifty-shades-of-bully/src/pages/components/playVideo.jsx

31 lines
954 B
React
Raw Normal View History

2025-04-18 04:34:55 +07:00
import '../../css/video.css';
2025-04-10 23:56:31 +07:00
function PlayVideo({ src = "hallway_MMM.mp4" ,side = "middle", onVideoReady }) {
2025-04-10 23:56:31 +07:00
const urlSource = `${import.meta.env.VITE_ASSETS_URL}/${src}`;
2025-04-18 04:34:55 +07:00
return (
<div className={`video-container ${side}`}>
2025-04-10 23:56:31 +07:00
<video
autoPlay
muted
controls="none"
playsInline
loop
pointerEvents="none"
2025-04-18 04:34:55 +07:00
onCanPlayThrough={(e) => {
e.target.play();
console.log("Video is ready and played");
if (onVideoReady) {
onVideoReady(); // Call the callback to notify that the video is ready
}
2025-04-10 23:56:31 +07:00
}}
>
2025-04-18 04:34:55 +07:00
<source src={urlSource} type="video/mp4" />
2025-04-10 23:56:31 +07:00
Your browser does not support the video tag.
</video>
</div>
2025-04-18 04:34:55 +07:00
);
2025-04-10 23:56:31 +07:00
}
2025-04-18 04:34:55 +07:00
export default PlayVideo;