Shinigami Hooks
useRemoteScreenShare

useRemoteScreenShare

The useRemoteScreenShare hook allows you to receive the media stream for another peer's screen being shared.

const {
    videoStream,
    audioStream,
    videoTrack,
    audioTrack,
    state,
  } = useRemoteScreenShare({
    peerId: "remote-peer-id",
    onPlayable(data) {},
    onClose() {},
  });

Props

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

1. peerIdRequired
DescriptionType
The peerId of the peer whose screenshare stream you want to consume.string
Example Usage
const remoteScreenShare = useRemoteScreenShare({ peerId: "remote-peer-id" });
2. onPlayableOptionalAdvanced
DescriptionReturn Type
This function will be called when the other peer has started sharing their screen and it can now be played on your end.void
Parameter NameTypeDescriptionRequired
data{track: MediaStreamTrack; stream: MediaStream; label: 'share-video' | 'share-audio';}The data object containing the media stream and media stream track that can be played.Yes
Example Usage
const remoteScreenShare = useRemoteScreenShare({ peerId: "remote-peer-id", onPlayable: (data) => {
	console.log("Ready to play remote peer's screen being shared!");
    // your code here
}});
3. onCloseOptionalAdvanced
DescriptionReturn Type
This function will be called when the other peer stops sharing their screen.void
Example Usage
const remoteScreenShare = useRemoteScreenShare({ peerId: "remote-peer-id", onClose: () => {
	console.log("Remote peer has stopped sharing their screen!");
    // your code here
}});

Returns

The useRemoteScreenShare hook returns an object with the following fields.

1. videoStreamObject
DescriptionType
The video stream for remote peer's screen which is being shared. null if screen not shared yet.MediaStream | null
2. audioStreamObject
DescriptionType
The audio stream for remote peer's screen which is being shared. null if screen not shared yet.MediaStream | null
3. videoTrackObject
DescriptionType
The video stream track for remote peer's screen which is being shared. null if screen not shared yet.MediaStreamTrack | null
4. audioTrackObject
DescriptionType
The audio stream track for remote peer's screen which is being shared. null if screen not shared yet.MediaStreamTrack | null
5. stateObject
DescriptionType
State of the remote peer's screenshare stream."playable" | "unavailable" | "stopped" | "paused" | "available"
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.