getUserMedia

View as Markdown

getUserMedia

  • Const getUserMedia(constraints?): Promise<MediaStream> — See MediaStream for more details.

Prompts the user to share one or more media devices and asynchronously returns an associated MediaStream object.

For more information, see MediaDevices.getUserMedia().

Parameters

constraints
MediaStreamConstraints

An optional MediaStreamConstraints object specifying requirements for the returned MediaStream.

Returns

Promise<MediaStream>

Examples

To only request audio media:

1await SignalWire.WebRTC.getUserMedia({ audio: true, video: false });
2// MediaStream {id: "HCXy...", active: true, ...}

To request both audio and video, specifying constraints for the video:

1const constraints = {
2 audio: true,
3 video: {
4 width: { min: 1024, ideal: 1280, max: 1920 },
5 height: { min: 576, ideal: 720, max: 1080 },
6 },
7};
8await SignalWire.WebRTC.getUserMedia(constraints);
9// MediaStream {id: "EDVk...", active: true, ...}