Entrypoint of OpenVidu Browser library. Use it to initialize objects of type Session, Publisher and LocalRecorder

### Hierarchy

- OpenVidu

## Index

### Constructors

- constructor

### Methods

- checkSystemRequirements
- enableProdMode
- getDevices
- getUserMedia
- initLocalRecorder
- initPublisher
- initPublisherAsync
- initSession
- setAdvancedConfiguration

## Constructors

### constructor

- new OpenVidu(): OpenVidu

- - Defined in OpenVidu/OpenVidu.ts:75

  #### Returns OpenVidu

## Methods

### checkSystemRequirements

- checkSystemRequirements(): number

- - Defined in OpenVidu/OpenVidu.ts:276

  Checks if the browser supports OpenVidu

  #### Returns number

  1 if the browser supports OpenVidu, 0 otherwise

### enableProdMode

- enableProdMode(): void

- - Defined in OpenVidu/OpenVidu.ts:393

  Disable all logging except error level

  #### Returns void

### getDevices

- getDevices(): Promise<Device[]>

- - Defined in OpenVidu/OpenVidu.ts:294

  Collects information about the media input devices available on the system. You can pass property `deviceId` of a Device object as value of `audioSource` or `videoSource` properties in initPublisher method

  #### Returns Promise<Device[]>

### getUserMedia

- getUserMedia(options: PublisherProperties): Promise<MediaStream>

- - Defined in OpenVidu/OpenVidu.ts:363

  Get a MediaStream object that you can customize before calling initPublisher (pass MediaStreamTrack property of the MediaStream value resolved by the Promise as `audioSource` or `videoSource` properties in initPublisher)

  Parameter `options` is the same as in initPublisher second parameter (of type PublisherProperties), but only the following properties will be applied: `audioSource`, `videoSource`, `frameRate`, `resolution`

  To customize the Publisher's video, the API for HTMLCanvasElement is very useful. For example, to get a black-and-white video at 10 fps and HD resolution with no sound:

      var OV = new OpenVidu();
      var FRAME_RATE = 10;

      OV.getUserMedia({
         audioSource: false;
         videoSource: undefined,
         resolution: '1280x720',
         frameRate: FRAME_RATE
      })
      .then(mediaStream => {

         var videoTrack = mediaStream.getVideoTracks()[0];
         var video = document.createElement('video');
         video.srcObject = new MediaStream([videoTrack]);

         var canvas = document.createElement('canvas');
         var ctx = canvas.getContext('2d');
         ctx.filter = 'grayscale(100%)';

         video.addEventListener('play', () => {
           var loop = () => {
             if (!video.paused && !video.ended) {
               ctx.drawImage(video, 0, 0, 300, 170);
               setTimeout(loop, 1000/ FRAME_RATE); // Drawing at 10 fps
             }
           };
           loop();
         });
         video.play();

         var grayVideoTrack = canvas.captureStream(FRAME_RATE).getVideoTracks()[0];
         var publisher = this.OV.initPublisher(
           myHtmlTarget,
           {
             audioSource: false,
             videoSource: grayVideoTrack
           });
      });

  #### Parameters

  - ##### options: PublisherProperties

  #### Returns Promise<MediaStream>

### initLocalRecorder

- initLocalRecorder(stream: Stream): LocalRecorder

- - Defined in OpenVidu/OpenVidu.ts:267

  Returns a new local recorder for recording streams straight away from the browser

  #### Parameters

  - ##### stream: Stream

    Stream to record

  #### Returns LocalRecorder

### initPublisher

- initPublisher(targetElement: string | HTMLElement): Publisher
- initPublisher(targetElement: string | HTMLElement, properties: PublisherProperties): Publisher
- initPublisher(targetElement: string | HTMLElement, completionHandler: function): Publisher
- initPublisher(targetElement: string | HTMLElement, properties: PublisherProperties, completionHandler: function): Publisher

- - Defined in OpenVidu/OpenVidu.ts:148

  Returns a new publisher

  #### Events dispatched

  The Publisher object will dispatch an `accessDialogOpened` event, only if the pop-up shown by the browser to request permissions for the camera is opened. You can use this event to alert the user about granting permissions for your website. An `accessDialogClosed` event will also be dispatched after user clicks on "Allow" or "Block" in the pop-up.

  The Publisher object will dispatch an `accessAllowed` or `accessDenied` event once it has been granted access to the requested input devices or not.

  The Publisher object will dispatch a `videoElementCreated` event once a HTML video element has been added to DOM (only if you let OpenVidu take care of the video players). See VideoElementEvent to learn more.

  The Publisher object will dispatch a `streamPlaying` event once the local streams starts playing. See StreamManagerEvent to learn more.

  #### Parameters

  - ##### targetElement: string | HTMLElement

    HTML DOM element (or its `id` attribute) in which the video element of the Publisher will be inserted (see PublisherProperties.insertMode). If null or undefined no default video will be created for this Publisher. You can always call method Publisher.addVideoElement or Publisher.createVideoElement to manage the video elements on your own (see Manage video players section)

  #### Returns Publisher

- - Defined in OpenVidu/OpenVidu.ts:149

  Returns a new publisher

  #### Events dispatched

  The Publisher object will dispatch an `accessDialogOpened` event, only if the pop-up shown by the browser to request permissions for the camera is opened. You can use this event to alert the user about granting permissions for your website. An `accessDialogClosed` event will also be dispatched after user clicks on "Allow" or "Block" in the pop-up.

  The Publisher object will dispatch an `accessAllowed` or `accessDenied` event once it has been granted access to the requested input devices or not.

  The Publisher object will dispatch a `videoElementCreated` event once a HTML video element has been added to DOM (only if you let OpenVidu take care of the video players). See VideoElementEvent to learn more.

  The Publisher object will dispatch a `streamPlaying` event once the local streams starts playing. See StreamManagerEvent to learn more.

  #### Parameters

  - ##### targetElement: string | HTMLElement

    HTML DOM element (or its `id` attribute) in which the video element of the Publisher will be inserted (see PublisherProperties.insertMode). If null or undefined no default video will be created for this Publisher. You can always call method Publisher.addVideoElement or Publisher.createVideoElement to manage the video elements on your own (see Manage video players section)

  - ##### properties: PublisherProperties

  #### Returns Publisher

- - Defined in OpenVidu/OpenVidu.ts:150

  Returns a new publisher

  #### Events dispatched

  The Publisher object will dispatch an `accessDialogOpened` event, only if the pop-up shown by the browser to request permissions for the camera is opened. You can use this event to alert the user about granting permissions for your website. An `accessDialogClosed` event will also be dispatched after user clicks on "Allow" or "Block" in the pop-up.

  The Publisher object will dispatch an `accessAllowed` or `accessDenied` event once it has been granted access to the requested input devices or not.

  The Publisher object will dispatch a `videoElementCreated` event once a HTML video element has been added to DOM (only if you let OpenVidu take care of the video players). See VideoElementEvent to learn more.

  The Publisher object will dispatch a `streamPlaying` event once the local streams starts playing. See StreamManagerEvent to learn more.

  #### Parameters

  - ##### targetElement: string | HTMLElement

    HTML DOM element (or its `id` attribute) in which the video element of the Publisher will be inserted (see PublisherProperties.insertMode). If null or undefined no default video will be created for this Publisher. You can always call method Publisher.addVideoElement or Publisher.createVideoElement to manage the video elements on your own (see Manage video players section)

  - ##### completionHandler: function

    `error` parameter is null if `initPublisher` succeeds, and is defined if it fails. `completionHandler` function is called before the Publisher dispatches an `accessAllowed` or an `accessDenied` event

    - - (error: Error | undefined): void

      - #### Parameters

        - ##### error: Error | undefined

        #### Returns void

  #### Returns Publisher

- - Defined in OpenVidu/OpenVidu.ts:151

  Returns a new publisher

  #### Events dispatched

  The Publisher object will dispatch an `accessDialogOpened` event, only if the pop-up shown by the browser to request permissions for the camera is opened. You can use this event to alert the user about granting permissions for your website. An `accessDialogClosed` event will also be dispatched after user clicks on "Allow" or "Block" in the pop-up.

  The Publisher object will dispatch an `accessAllowed` or `accessDenied` event once it has been granted access to the requested input devices or not.

  The Publisher object will dispatch a `videoElementCreated` event once a HTML video element has been added to DOM (only if you let OpenVidu take care of the video players). See VideoElementEvent to learn more.

  The Publisher object will dispatch a `streamPlaying` event once the local streams starts playing. See StreamManagerEvent to learn more.

  #### Parameters

  - ##### targetElement: string | HTMLElement

    HTML DOM element (or its `id` attribute) in which the video element of the Publisher will be inserted (see PublisherProperties.insertMode). If null or undefined no default video will be created for this Publisher. You can always call method Publisher.addVideoElement or Publisher.createVideoElement to manage the video elements on your own (see Manage video players section)

  - ##### properties: PublisherProperties

  - ##### completionHandler: function

    `error` parameter is null if `initPublisher` succeeds, and is defined if it fails. `completionHandler` function is called before the Publisher dispatches an `accessAllowed` or an `accessDenied` event

    - - (error: Error | undefined): void

      - #### Parameters

        - ##### error: Error | undefined

        #### Returns void

  #### Returns Publisher

### initPublisherAsync

- initPublisherAsync(targetElement: string | HTMLElement): Promise<Publisher>
- initPublisherAsync(targetElement: string | HTMLElement, properties: PublisherProperties): Promise<Publisher>

- - Defined in OpenVidu/OpenVidu.ts:238

  Promisified version of OpenVidu.initPublisher

  > WARNING: events `accessDialogOpened` and `accessDialogClosed` will not be dispatched if using this method instead of OpenVidu.initPublisher

  #### Parameters

  - ##### targetElement: string | HTMLElement

  #### Returns Promise<Publisher>

- - Defined in OpenVidu/OpenVidu.ts:239

  #### Parameters

  - ##### targetElement: string | HTMLElement

  - ##### properties: PublisherProperties

  #### Returns Promise<Publisher>

### initSession

- initSession(): Session

- - Defined in OpenVidu/OpenVidu.ts:142

  Returns new session

  #### Returns Session

### setAdvancedConfiguration

- setAdvancedConfiguration(configuration: OpenViduAdvancedConfiguration): void

- - Defined in OpenVidu/OpenVidu.ts:408

  Set OpenVidu advanced configuration options. Currently `configuration` is an object with the following optional properties (see OpenViduAdvancedConfiguration for more details):

  - `iceServers`: set custom STUN/TURN servers to be used by OpenVidu Browser
  - `screenShareChromeExtension`: url to a custom screen share extension for Chrome to be used instead of the default one, based on ours https://github.com/OpenVidu/openvidu-screen-sharing-chrome-extension
  - `publisherSpeakingEventsOptions`: custom configuration for the PublisherSpeakingEvent feature

  #### Parameters

  - ##### configuration: OpenViduAdvancedConfiguration

  #### Returns void

Generated using TypeDoc