useDisplayMedia ​
Hook that provides screen sharing functionality using the Display Media API
typescript
import { useDisplayMedia } from '@siberiacancode/reactuse';
Usage ​
typescript
const { stream, sharing, start, stop } = useDisplayMedia(ref);
// or
const { ref, stream, sharing, start, stop } = useDisplayMedia<HTMLVideoElement>();
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
target | Target | - | The target video element to display the media stream |
options.audio? | boolean | MediaTrackConstraints | - | Whether to enable audio sharing |
options.enabled? | boolean | false | Whether to start immediately |
options.video? | boolean | MediaTrackConstraints | - | Whether to enable video sharing |
Returns
Parameters
Name | Type | Default | Note |
---|---|---|---|
options.audio? | boolean | MediaTrackConstraints | - | Whether to enable audio sharing |
options.enabled? | boolean | false | Whether to start immediately |
options.video? | boolean | MediaTrackConstraints | - | Whether to enable video sharing |