Shinigami Hooks
useLocalVideo

useLocalVideo

The useLocalVideo hook exposes primitives to interact with your own video stream - coming from your camera device.

const {
    stream,
    track,
    enableVideo,
    disableVideo,
  } = useLocalVideo({
    onProduceStart(producer) {},
    onProduceClose() {},
    onProduceError() {},
  });

Props

The useLocalVideo hook accepts an object with the following fields as props.

1. onProduceStartOptionalAdvanced
DescriptionReturn Type
This function will be called when you start producing your camera's video stream i.e sharing it with other peers in the room.void
Parameter NameTypeDescriptionRequired
producerProducerThe mediasoup producer object.Yes
Example Usage
const localVideo = useLocalVideo({ onProduceStart: (producer) => {
	console.log("Started producing your video stream!");
	console.log(producer);
    // your code here
}});
2. onProduceCloseOptionalAdvanced
DescriptionReturn Type
This function will be called when you stop producing your camera's video stream.void
Example Usage
const localVideo = useLocalVideo({ onProduceClose: () => {
	console.log("Stopped producing your video stream!");
    // your code here
}});
3. onProduceErrorOptionalAdvanced
DescriptionReturn Type
This function will be called when there was an error encountered while producing your camera's video stream.void
Example Usage
const localVideo = useLocalVideo({ onProduceError: () => {
	console.log("There was an error in producing your video stream!");
    // your code here
}});

Returns

The useLocalVideo hook returns an object with the following fields.

1. streamObject
DescriptionType
Your camera's video stream. null if not enabled yet.MediaStream | null
2. trackObject
DescriptionType
Your camera's video stream track. null if not enabled yet.MediaStreamTrack | null
3. enableVideoFunction
DescriptionReturn Type
Enable your camera's video stream and start producing it with other peers in the room.Promise<void>
4. disableVideoFunction
DescriptionReturn Type
Disable your camera's video stream and stop producing it with other peers in the room.Promise<void>
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.