Home Manual Reference Source
public class | source

Media

Helpers for MediaDevices and MediaStreamConstraints.

Static Member Summary

Static Public Members
public static get

facingMode: {USER: string, ENVIRONMENT: string}: {"USER": string, "ENVIRONMENT": string}

facingMode values to use with constraints

Static Method Summary

Static Public Methods
public static

attachStream(mediaStream: MediaStream, container: Element, previous: Element, volume: number): Element

Init stream display node depending on stream type

public static

constraints(videoConstraints: boolean | MediaTrackConstraints | string, audioConstraints: boolean | MediaTrackConstraints, type: string, videoDeviceId: string | object, audioDeviceId: string | object): object

Helpers to create a MediaStreamConstraints configuration object

public static

devices(): Promise<{audioinput: MediaDeviceInfo[], videoinput: MediaDeviceInfo[]}>

List available input devices

Static Public Members

public static get facingMode: {USER: string, ENVIRONMENT: string}: {"USER": string, "ENVIRONMENT": string} source

facingMode values to use with constraints

Return:

{USER: string, ENVIRONMENT: string}

Static Public Methods

public static attachStream(mediaStream: MediaStream, container: Element, previous: Element, volume: number): Element source

Init stream display node depending on stream type

Params:

NameTypeAttributeDescription
mediaStream MediaStream

The MediaStream to display

container Element

Container node for streams

previous Element

Previous node for the stream

volume number
  • optional
  • default: .7

the default volume

Return:

Element

public static constraints(videoConstraints: boolean | MediaTrackConstraints | string, audioConstraints: boolean | MediaTrackConstraints, type: string, videoDeviceId: string | object, audioDeviceId: string | object): object source

Helpers to create a MediaStreamConstraints configuration object

Params:

NameTypeAttributeDescription
videoConstraints boolean | MediaTrackConstraints | string
  • optional
  • default: 'HD'

a boolean, a video constraints object or a preset id (UHD, FHD, HD, SVGA, SD, VGA)

audioConstraints boolean | MediaTrackConstraints
  • optional
  • default: true

a boolean or an audio constraints object

type string
  • optional
  • default: ideal

type of constraints for video when using a preset (exact,min,max or ideal)

videoDeviceId string | object
  • optional

video input device id or facingMode

audioDeviceId string | object
  • optional

audio input device id

Return:

object

Throw:

Error

Example:

HD AudioVideo with default devices
let myConstraints = Reach.media.constraints();
console.log(myConstraints);
Full HD Video without audio using default devices
let myConstraints = Reach.media.constraints('FHD', false, 'exact');
console.log(myConstraints);

public static devices(): Promise<{audioinput: MediaDeviceInfo[], videoinput: MediaDeviceInfo[]}> source

List available input devices

Return:

Promise<{audioinput: MediaDeviceInfo[], videoinput: MediaDeviceInfo[]}>

Example:

Reach.media.devices().then(devices => {
 // Video cameras
 console.log(devices.videoinput);
 // Audio mics
 console.log(devices.audioinput);
});