diff --git a/src/components/StreamComponent.js b/src/components/StreamComponent.js index e69de29..1046b2d 100644 --- a/src/components/StreamComponent.js +++ b/src/components/StreamComponent.js @@ -0,0 +1,77 @@ +import React, { useEffect, useRef, useState } from 'react'; + +const StreamComponent = () => { + const videoRef = useRef(null); + const [isLoading, setIsLoading] = useState(false); + const [ipAddress, setIpAddress] = useState(''); + const [streamed, setStreamed] = useState(false); // Track whether the video has streamed + + useEffect(() => { + const video = videoRef.current; + + const handleCanPlayThrough = () => { + setIsLoading(false); + setStreamed(true); + if (video && video.paused) { + video.play().catch(error => { + console.error('Error playing the video:', error); + }); + } + }; + + if (video && ipAddress && isLoading) { + video.addEventListener('canplaythrough', handleCanPlayThrough); + setIsLoading(true); + + const streamUrl = `http://${ipAddress}/api/holographic/stream/live_high.mp4`; + video.src = streamUrl; + } + + return () => { + if (video) { + video.removeEventListener('canplaythrough', handleCanPlayThrough); + } + }; + }, [ipAddress, isLoading]); + + const handleVideoClick = () => { + const video = videoRef.current; + if (video && video.paused) { + video.play().catch(error => { + console.error('Error playing the video:', error); + }); + } + }; + + const handleInputChange = (event) => { + setIpAddress(event.target.value); + setStreamed(false); // Reset streamed state when the input changes + }; + + const handleOkButtonClick = () => { + setIsLoading(true); + setStreamed(false); // Reset streamed state when the OK button is pressed + }; + + return ( + <> + {!streamed && ( + <> + + + > + )} + + {isLoading && !streamed &&
This page will display samples that have been collected, and what samples should be kept
diff --git a/src/pages/rocks.js b/src/pages/rocks.js index 2f21c56..78f155e 100644 --- a/src/pages/rocks.js +++ b/src/pages/rocks.js @@ -1,33 +1,11 @@ import React from 'react'; import './../pages-style/rocks.css'; -import { ProcedureList } from '../helpers/ProcedureList'; -import ProcedureItem from '../components/ProcedureItem'; + function Rocks() { return (This page will display samples that have been collected, and what samples should be kept
-Warning: Are you sure you want to proceed?
-