Interface in charge of displaying the media streams in the HTML DOM. This wraps any Publisher and Subscriber object. You can insert as many video players fo the same Stream as you want by calling StreamManager.addVideoElement or StreamManager.createVideoElement.

The use of StreamManager wrapper is particularly useful when you don't need to differentiate between Publisher or Subscriber streams or just want to directly manage your own video elements (even more than one video element per Stream). This scenario is pretty common in declarative, MVC frontend frameworks such as Angular, React or Vue.js

### Hierarchy

- StreamManager
  - Publisher
  - Subscriber

### Implements

- EventDispatcher

## Index

### Properties

- id
- remote
- stream
- targetElement
- videos

### Methods

- addVideoElement
- createVideoElement
- off
- on
- once

## Properties

### id

id: string

- Defined in OpenVidu/StreamManager.ts:69

`id` attribute of the DOM video element displaying the Publisher/Subscriber's stream. This property is only defined if:

- Publisher has been initialized by calling method OpenVidu.initPublisher with a valid `targetElement` parameter
- Subscriber has been initialized by calling method Session.subscribe with a valid `targetElement` parameter

### remote

remote: boolean

- Defined in OpenVidu/StreamManager.ts:55

Whether the Stream represented in the DOM is local or remote

- `false` for Publisher
- `true` for Subscriber

### stream

stream: Stream

- Defined in OpenVidu/StreamManager.ts:43

The Stream represented in the DOM by the Publisher/Subscriber

### targetElement

targetElement: HTMLElement

- Defined in OpenVidu/StreamManager.ts:62

The DOM HTMLElement assigned as target element when creating the video for the Publisher/Subscriber. This property is only defined if:

- Publisher has been initialized by calling method OpenVidu.initPublisher with a valid `targetElement` parameter
- Subscriber has been initialized by calling method Session.subscribe with a valid `targetElement` parameter

### videos

videos: StreamManagerVideo[] = []

- Defined in OpenVidu/StreamManager.ts:48

All the videos displaying the Stream of this Publisher/Subscriber

## Methods

### addVideoElement

- addVideoElement(video: HTMLVideoElement): number

- - Defined in OpenVidu/StreamManager.ts:220

  Makes `video` element parameter display this stream. This is useful when you are managing the video elements on your own

  Calling this method with a video already added to other Publisher/Subscriber will cause the video element to be disassociated from that previous Publisher/Subscriber and to be associated to this one.

  #### Parameters

  - ##### video: HTMLVideoElement

  #### Returns number

  1 if the video wasn't associated to any other Publisher/Subscriber and has been successfully added to this one. 0 if the video was already added to this Publisher/Subscriber. -1 if the video was previously associated to any other Publisher/Subscriber and has been successfully disassociated from that one and properly added to this one.

### createVideoElement

- createVideoElement(targetElement?: string | HTMLElement, insertMode?: VideoInsertMode): HTMLVideoElement

- - Defined in OpenVidu/StreamManager.ts:266

  Creates a new video element displaying this stream. This allows you to have multiple video elements displaying the same media stream.

  #### Events dispatched

  The Publisher/Subscriber object will dispatch a `videoElementCreated` event once the HTML video element has been added to DOM. See VideoElementEvent

  #### Parameters

  - ##### Optional targetElement: string | HTMLElement

    HTML DOM element (or its `id` attribute) in which the video element of the Publisher/Subscriber will be inserted

  - ##### Optional insertMode: VideoInsertMode

    How the video element will be inserted accordingly to `targetElemet`

  #### Returns HTMLVideoElement

### off

- off(type: string, handler?: function): StreamManager

- - Defined in OpenVidu/StreamManager.ts:200

  See EventDispatcher.off

  #### Parameters

  - ##### type: string

  - ##### Optional handler: function

    - - (event: Event): void

      - #### Parameters

        - ##### event: Event

        #### Returns void

  #### Returns StreamManager

### on

- on(type: string, handler: function): EventDispatcher

- - Defined in OpenVidu/StreamManager.ts:139

  See EventDispatcher.on

  #### Parameters

  - ##### type: string

  - ##### handler: function

    - - (event: Event): void

      - #### Parameters

        - ##### event: Event

        #### Returns void

  #### Returns EventDispatcher

### once

- once(type: string, handler: function): StreamManager

- - Defined in OpenVidu/StreamManager.ts:170

  See EventDispatcher.once

  #### Parameters

  - ##### type: string

  - ##### handler: function

    - - (event: Event): void

      - #### Parameters

        - ##### event: Event

        #### Returns void

  #### Returns StreamManager

Generated using TypeDoc