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 {Button, View, Text} from 'react-native';
import {useLivestream} from '@huddle01/react-native/hooks';
const App = () => {
const { startLivestream, stopLivestream, isStarting, inProgress isStopping, error } = useLivestream();
if(inProgress) return (<View><Text>Loading...</Text></View>)
return (
<View>
<View style={styles.button}>
<Button
title="START_LIVESTREAM"
disabled={!startLivestream.isCallable}
onPress={startLivestream}
/>
</View>
{isStarting ? <Text>"live stream is starting"</Text>: error}
<View style={styles.button}>
<Button
title="STOP_LIVESTREAM"
disabled={!stopLivestream.isCallable}
onPress={stopLivestream}
/>
</View>
</View>
);
};