# Media

User Media

## Constructor

#### new Media(constraintsopt)

Source:
  - media/Media.js, line 8

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`constraints` | object | <optional> | `{ video: { width: { ideal: 1920 }, height: { ideal: 1080 }, facingMode: { exact: 'environment' } }, audio: false }` |

### Methods

#### createVideoElement() → {HTMLVideoElement}

Source:
  - media/Media.js, line 289

Create video element

##### Fires:

- Media#event:canplay

##### Returns:

Type
  HTMLVideoElement

#### createVideoTexture() → {THREE.VideoTexture}

Source:
  - media/Media.js, line 265

Create video texture

##### Returns:

Type
  THREE.VideoTexture

#### enumerateDevices() → {Promise}

Source:
  - media/Media.js, line 44

Enumerate devices

##### Returns:

Type
  Promise

#### getDevices(type)

Source:
  - media/Media.js, line 90

Get devices

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | string | type keyword to match device.kind

#### getUserMedia(constraints)

Source:
  - media/Media.js, line 122

Get user media

##### Parameters:

Name | Type | Description
--- | --- | ---
`constraints` | MediaStreamConstraints |

#### onWindowResize(event)

Source:
  - media/Media.js, line 326

On window resize event

##### Parameters:

Name | Type | Description
--- | --- | ---
`event` | Event |

#### pauseVideo()

Source:
  - media/Media.js, line 246

Pause video element

#### playVideo()

Source:
  - media/Media.js, line 228

Play video element

#### setMediaStream(stream)

Source:
  - media/Media.js, line 208

Set media stream

##### Parameters:

Name | Type | Description
--- | --- | ---
`stream` | MediaStream |

#### setVideDeviceIndex(index)

Source:
  - media/Media.js, line 141

Set video device index

##### Parameters:

Name | Type | Description
--- | --- | ---
`index` | number |

#### start(targetDeviceopt)

Source:
  - media/Media.js, line 153

Start streaming

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`targetDevice` | MediaDeviceInfo | <optional> |

#### stop()

Source:
  - media/Media.js, line 183

Stop streaming

#### switchNextVideoDevice()

Source:
  - media/Media.js, line 58

Switch to next available video device

### Events

#### canplay

Source:
  - media/Media.js, line 294

Video can play event

##### Type:

- object