useVideo

⚠️

If cam isn’t enabled in the lobby, video won’t be shareable inside the room

⚠️

The method is to be called only when in lobby state.

These are the fields which are returned from useVideo hook.

NameType
fetchVideoStream(deviceId?: string)FunctionEnables video stream from user’s webcam(lobby)
stopVideoStream()FunctionDisables video stream from user’s device cam(lobby)
produceVideo()FunctionStarts sharing user’s webcam video stream with other peers in the room
stopProducingVideo()FunctionStops sharing user’s webcam video stream with other peers in the room
switchCamera()FunctionSwitches between video stream coming from user’s front and rear device webcams
isFrontCamerabooleanBoolean indicating whether the video stream is coming from user's front cam or rear
isLoadingbooleanloading state
isProducingbooleanstate whether the video is producing or not
streamMediaStreamvideo stream
errorstringgives the error message

Sample Code

import {Button, View} from 'react-native';
import { useVideo } from '@huddle01/react-native/hooks';
 
const App = () => {
  const { fetchVideoStream, stopVideoStream, isProducing, switchCamera, isFrontCamera, stream, error} = useVideo();
 
  return (
    <View>
      <View style={styles.button}>
        <Button
          title="FETCH_VIDEO_STREAM"
          disabled={!fetchVideoStream.isCallable}
          onPress={fetchVideoStream}
        />
      </View>
 
      <View style={styles.button}>
        <Button
          title="STOP_VIDEO_STREAM"
          disabled={!stopVideoStream.isCallable}
          onPress={stopVideoStream}
        />
      </View>
 
      <View style={styles.button}>
        <Button
          title="SWITCH_CAMERA"
          onPress={switchCamera}
        />
      </View>
    </View>
  );
};
 
 
Audio/Video Infrastructure designed for the developers to empower them ship simple yet powerful Audio/Video Apps.
support
company
Copyright © 2022 Graphene 01, Inc. All Rights Reserved.