useVideo

useVideo

💡

produceVideo() method takes list of peerId as an optional argument, by default it will produce video for all peers.

These are the fields which are returned from useVideo hook.

NameType
fetchVideoStream()FunctionEnables video stream from user’s device mic(lobby)
stopVideoStream()FunctionDisables video stream from user’s device mic(lobby)
produceVideo(camStream: MediaStream, peerIds?: string[])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
enumerateDevices()FunctionReturns the list of video devices
createCamConsumer(peerId: string)FunctionStarts consuming video stream of given peerId
closeCamConsumer(peerId: string)FunctionStops consuming video stream of given peerId
isLoadingbooleanloading state
isProducingbooleanstate whether the video is producing or not
streamMediaStreamvideo stream
errorstringgives the error message

Sample Code

 
import { useVideo } from '@huddle01/react/hooks';
 
const App = () => {
  const { fetchVideoStream, stopVideoStream, isProducing, stream, error} = useVideo();
 
  return (
    <div>
      
     {/* Mic */} 
      <button disabled={!fetchVideoStream.isCallable} onClick={fetchVideoStream}>
        FETCH_VIDEO_STREAM
      </button>
 
    </div>
  );
};
 
 
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.