useLivestream
useLivestream hook allows you to use following methods & states.
Name | Type | |
---|---|---|
startLivestream() | Function | starts live-streaming the web app on the given sourceUrl |
stopLivestream() | Function | stops the live-stream on the web app |
isStarting | boolean | state whether the livestream has started or not |
inProgress | boolean | state whether the livestream is in progress |
isStopping | boolean | state whether the livestream has stopped or not |
data | data | data of the livestream |
error | string | gives the error message |
Sample code
import { useLivestream } from '@huddle01/react/hooks';
const App = () => {
const { startLivestream,stopLivestream, isStarting, inProgress isStopping, error } = useLivestream();
if(inProgress) return (<div>...loading</div>)
return (
<div>
<button
disabled={!startLivestream.isCallable}
onClick={startLivestream}
>
START_LIVESTREAM
</button>
{isStarting ? "live stream is starting": error}
<button disabled={!stopLivestream.isCallable} onClick={stopLivestream}>
STOP_LIVESTREAM
</button>
</div>
);
};