-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMPROVE] Change minor UI for mainstage (#124)
* Restyle mainstage * Add error alert * remove unused code * Update app/components/clientsideonly/videostreamer.js Co-authored-by: Debdut Chakraborty <[email protected]>
- Loading branch information
Showing
3 changed files
with
69 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,82 @@ | ||
import { Col } from 'react-bootstrap'; | ||
import styles from '../../styles/Videostreamer.module.css'; | ||
import Script from 'next/script'; | ||
import Head from 'next/head'; | ||
import { Col, Toast, ToastContainer } from "react-bootstrap"; | ||
import styles from "../../styles/Videostreamer.module.css"; | ||
import Script from "next/script"; | ||
import Head from "next/head"; | ||
import { useEffect, useState } from "react"; | ||
|
||
export default function Videostreamer(props) { | ||
const [ping, setPing] = useState(false) | ||
const pingStream = async () => { | ||
const response = await fetch(props.src) | ||
if (response.ok) { | ||
setPing(true) | ||
} | ||
return; | ||
} | ||
useEffect(() => { | ||
setInterval(() => { | ||
pingStream().catch(e => { | ||
console.error("Stream error", e) | ||
setPing(false) | ||
}) | ||
}, 60000) | ||
|
||
}, []) | ||
|
||
const handleToast = () => { | ||
setPing(true) | ||
} | ||
return ( | ||
<> | ||
<Head> | ||
<link | ||
href='https://vjs.zencdn.net/7.17.0/video-js.css' | ||
rel='stylesheet' | ||
href="https://vjs.zencdn.net/7.17.0/video-js.css" | ||
rel="stylesheet" | ||
/> | ||
</Head> | ||
<Script | ||
src='https://vjs.zencdn.net/7.17.0/video.min.js' | ||
strategy='afterInteractive' | ||
src="https://vjs.zencdn.net/7.17.0/video.min.js" | ||
strategy="afterInteractive" | ||
onLoad={() => | ||
console.log(`script loaded correctly, window.FB has been populated`) | ||
} | ||
/> | ||
<Col> | ||
<video-js | ||
fluid | ||
id='my-video' | ||
class='video-js vjs-big-play-centered' | ||
<video | ||
autoPlay | ||
id="my-video" | ||
class="video-js vjs-big-play-centered vjs-responsive" | ||
controls | ||
preload='auto' | ||
width='1280' | ||
height='720' | ||
preload="auto" | ||
poster={props.poster} | ||
data-setup='{"fluid": true}' | ||
> | ||
<source src={props.src} type={props.type}></source> | ||
</video-js> | ||
<p class="vjs-no-js"> | ||
To view this video please enable JavaScript, and consider upgrading | ||
to a web browser that | ||
<a href="https://videojs.com/html5-video-support/" target="_blank"> | ||
supports HTML5 video | ||
</a> | ||
</p> | ||
</video> | ||
<Alert show={!ping} handleToast={handleToast}/> | ||
|
||
</Col> | ||
</> | ||
); | ||
} | ||
|
||
const Alert = ({handleToast, show}) => { | ||
return ( | ||
<ToastContainer show={show} position="bottom-start" style={{zIndex: "10"}} className="p-3"> | ||
<Toast show={show} onClose={handleToast} bg="info"> | ||
<Toast.Header> | ||
<strong className="me-auto">Stream Alert!</strong> | ||
<small className="text-muted">just now</small> | ||
</Toast.Header> | ||
<Toast.Body>Thank you for tuning in! Looks like the streaming has stopped! Please stay tune!</Toast.Body> | ||
</Toast> | ||
</ToastContainer> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters