This class can be used to preview media functionality. For example, you can preview the video and audio to verify that everything is looking good before joining a room.
const previewPublisher = new VideoExpress.PreviewPublisher('previewContainer');
await previewPublisher.previewMedia({
targetElement: 'previewContainer',
publisherProperties: {
resolution: '1280x720',
frameRate: 15,
},
});
Also, before joining a room, a new camera publisher is initialised,
so it is recommended to destroy the previewPublisher
(by calling
its destroy()
method) before calling room.join()
code>.
Methods
Name | Description | ||||||
---|---|---|---|---|---|---|---|
(Promise<void>)
clearVideoFilter
()
|
Returns a Promise that resolves to |
||||||
(void)
destroy
()
|
Destroys the preview media. | ||||||
(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 .
|
||||||
(Promise<void>)
previewMedia
(publisherOptions)
|
Initializes a preview publisher. Optionally It receives publisherOptions
object which is described here.
|
||||||
(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:
|
||||||
(void)
setDisabledImageURI
(disabledImageURI)
|
Accepts an image URI (string) and updates the publisher
|
||||||
(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:
|
||||||
(Promise<void>)
setVideoFilter
(videoFilter)
|
Returns a Promise that resolves to
The following errors may be thrown when using
|
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 preview 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 preview publisher is created. This event does not emit anything. |
destroyed
|
Dispatched when the preview publisher is destroyed. This event does not emit anything. |