Suggestions

close search

Add Messaging, Voice, and Authentication to your apps with Vonage Communications APIs

Visit the Vonage API Developer Portal

VideoExpress.Room.CameraPublisher

Methods Events 

Provides the mechanism for controlling the published stream. You can access the CameraPublisher via the camera property of the Room object, after you have successfully joined a session:

const room = new VideoExpress.Room(roomProperties);
await room.join();
const { camera } = room;

            

Methods

Name Description
(Promise<void>) clearVideoFilter ()

Returns a Promise that resolves to void. This method removes the filter that is applied to the Publisher. If no filter is currently applied, it fails silently.

(void) disableAudio () Disables the audio track.
(void) disableVideo () Disables the video track.
(void) enableAudio () Enables the audio track.
(void) enableVideo () Enables the video track.
(Promise<device>) getAudioDevice () Returns a device object which contains the deviceId, label and kind.
(device) getVideoDevice () Returns a device object which contains the deviceId, label and kind.
(boolean) isAudioEnabled () Returns true when the audio track is enabled. Otherwise it returns false.
(boolean) isVideoEnabled () Returns true when the video track is enabled. Otherwise it returns false.
(void) setAudioDevice (deviceId)

Switches the audio input source. Pass in the device ID of the new audio source.

Calling this method results in an error (the Promise returned by the method is rejected) in the following conditions:

  • The browser does not support this method.
  • The publisher was not initiated with an audio source. (The audioSource option of the OT.initPublisher() method was set to nullcode> or false).
  • The user denied access to the audio input device.
  • There was an error acquiring audio from the audio input device or MediaStreamTrack object.
  • The audioSource value is not a string or MediaStreamTrack object.
  • The audioSource string is not a valid audio input device available to the browser.

(void) setDisabledImageURI (disabledImageURI)

Accepts an image URI (string) and updates the publisher backgroundImageURI property. Currently supported image formats include: PNG, JPEG, or a non-animated GIF. You can also use the data URI scheme and pass in base-64-encrypted PNG data or SVG data. If the URL or image data is invalid, the property is ignored and a default image is set. Returns void.

(void) setVideoDevice (deviceId)

This method sets the video source for a publisher that is using a camera. Pass in the device ID of the new video source.

The following result in errors:

  • The deviceId parameter is not a string or the device ID for a valid video input device, the promise is rejected with an error with the name property set to 'OT_INVALID_VIDEO_SOURCE'.
  • The publisher does not currently use a camera input, the promise is rejected with an error with the name property set to 'OT_SET_VIDEO_SOURCE_FAILURE'.

(Promise<void>) setVideoFilter (videoFilter)

Returns a Promise that resolves to void. Accepts a VideoFilter object with properties that define the video filter to be applied to the Publisher's video stream.

Name Type Description
videoFilter Object An object defining the video filter to be applied. The following filters are supported:
  • Background blur filter: — Set the type property of the object to "backgroundBlur".

    A background blur filter object includes an additional blurStrength property, which defines the blur radius and is optional. Set this to either "low" or "high" (the default).

  • Background replacement filter — Set the type property of the object to "backgroundReplacement".

    A background replacement filter object includes an additional backgroundImgUrl property, which defines the URL of the background image to use. Also accepted are image BLOBs (a Base64-encoded string of image data). The following image formats are supported: BMP, PNG, JPEG, and GIF.

The following errors may be thrown when using setVideoFilter:

  • OT_NOT_SUPPORTED - browser does not support video filters;
  • OT_INVALID_VIDEO_SOURCE - Publisher is using unsupported video source: null, false, or screen;
  • OT_INVALID_PARAMETER - one or more parameters are incorrect.

Events

Name Description
accessAllowed Dispatched when the user granted access to the device camera and mic. This event does not emit anything.
accessDenied Dispatched when the user denied access to the device camera and mic. This event does not emit anything.
accessDialogClosed Dispatched when the user closes the dialog box to allow or deny access to the camera and mic. This event does not emit anything.
accessDialogOpened Dispatched when the browser prompted a dialog box to allow or deny access to the camera and mic. This event does not emit anything.
audioLevelUpdated Emits audioLevel (Number). Dispatched periodically by the camera publisher to indicate the audio level. This event is dispatched up to 60 times per second, depending on the browser. The audioLevel value is the audio level, from 0 to 1.0.
created Dispatched when the camera publisher is created. This event does not emit anything.
destroyed Dispatched when the camera publisher is destroyed. This event does not emit anything.