Packs local media streams. Participants can publish it to a session. Initialized with OpenVidu.initPublisher method

### Hierarchy

- StreamManager
  - Publisher

### Implements

- EventDispatcher

## Index

### Properties

- accessAllowed
- id
- isSubscribedToRemote
- openvidu
- remote
- session
- stream
- targetElement
- videos

### Methods

- addVideoElement
- createVideoElement
- off
- on
- once
- publishAudio
- publishVideo
- subscribeToRemote

## Properties

### accessAllowed

accessAllowed: boolean = false

- Defined in OpenVidu/Publisher.ts:42

Whether the Publisher has been granted access to the requested input devices or not

### id

id: string

Inherited from StreamManager.id

- 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

### isSubscribedToRemote

isSubscribedToRemote: boolean = false

- Defined in OpenVidu/Publisher.ts:47

Whether you have called Publisher.subscribeToRemote with value `true` or `false` (false by default)

### openvidu

openvidu: OpenVidu

- Defined in OpenVidu/Publisher.ts:61

hidden

### remote

remote: boolean

Inherited from StreamManager.remote

- Defined in OpenVidu/StreamManager.ts:55

Whether the Stream represented in the DOM is local or remote

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

### session

session: Session

- Defined in OpenVidu/Publisher.ts:52

The Session to which the Publisher belongs

### stream

stream: Stream

Inherited from StreamManager.stream

- Defined in OpenVidu/StreamManager.ts:43

The Stream represented in the DOM by the Publisher/Subscriber

### targetElement

targetElement: HTMLElement

Inherited from StreamManager.targetElement

- 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[] = []

Inherited from StreamManager.videos

- Defined in OpenVidu/StreamManager.ts:48

All the videos displaying the Stream of this Publisher/Subscriber

## Methods

### addVideoElement

- addVideoElement(video: HTMLVideoElement): number

- Inherited from StreamManager.addVideoElement

  - 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

- Inherited from StreamManager.createVideoElement

  - Defined in OpenVidu/StreamManager.ts:264

  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

- Inherited from StreamManager.off

  - 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

- Overrides StreamManager.on

  - Defined in OpenVidu/Publisher.ts:185

  See EventDispatcher.on

  #### Parameters

  - ##### type: string

  - ##### handler: function

    - - (event: Event): void

      - #### Parameters

        - ##### event: Event

        #### Returns void

  #### Returns EventDispatcher

### once

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

- Overrides StreamManager.once

  - Defined in OpenVidu/Publisher.ts:222

  See EventDispatcher.once

  #### Parameters

  - ##### type: string

  - ##### handler: function

    - - (event: Event): void

      - #### Parameters

        - ##### event: Event

        #### Returns void

  #### Returns Publisher

### publishAudio

- publishAudio(value: boolean): void

- - Defined in OpenVidu/Publisher.ts:103

  Publish or unpublish the audio stream (if available). Calling this method twice in a row passing same value will have no effect

  #### Events dispatched

  The Session object of the local participant will dispatch a `streamPropertyChanged` event with `changedProperty` set to `"audioActive"` and `reason` set to `"publishAudio"` The Publisher object of the local participant will also dispatch the exact same event

  The Session object of every other participant connected to the session will dispatch a `streamPropertyChanged` event with `changedProperty` set to `"audioActive"` and `reason` set to `"publishAudio"` The respective Subscriber object of every other participant receiving this Publisher's stream will also dispatch the exact same event

  See StreamPropertyChangedEvent to learn more.

  #### Parameters

  - ##### value: boolean

    `true` to publish the audio stream, `false` to unpublish it

  #### Returns void

### publishVideo

- publishVideo(value: boolean): void

- - Defined in OpenVidu/Publisher.ts:145

  Publish or unpublish the video stream (if available). Calling this method twice in a row passing same value will have no effect

  #### Events dispatched

  The Session object of the local participant will dispatch a `streamPropertyChanged` event with `changedProperty` set to `"videoActive"` and `reason` set to `"publishVideo"` The Publisher object of the local participant will also dispatch the exact same event

  The Session object of every other participant connected to the session will dispatch a `streamPropertyChanged` event with `changedProperty` set to `"videoActive"` and `reason` set to `"publishVideo"` The respective Subscriber object of every other participant receiving this Publisher's stream will also dispatch the exact same event

  See StreamPropertyChangedEvent to learn more.

  #### Parameters

  - ##### value: boolean

    `true` to publish the video stream, `false` to unpublish it

  #### Returns void

### subscribeToRemote

- subscribeToRemote(value?: boolean): void

- - Defined in OpenVidu/Publisher.ts:175

  Call this method before Session.publish if you prefer to subscribe to your Publisher's remote stream instead of using the local stream, as any other user would do.

  #### Parameters

  - ##### Optional value: boolean

  #### Returns void

Generated using TypeDoc