Skip to main content

Class: Video

The Video Class allows you to create WebRTC Video Experiences from websites and applications using Twilio Video WebRTC

Throughout this page, you will see videoClient with a lowercase "v" and Video with an uppercase "V".

Video refers to the Video object provided by the SDK.

videoClient represents an instance of a Video, created with the new keyword:

Instantiate a Video Client​

A new instance of Video should be constructed by using the new keyword and passing the Config payload as the first argument.

No signaling channel will be opened when instantiating a new Video Client. The signaling WebSocket will be opened when videoClient.connect() is called.

The maximum number of characters for the identity provided in the Access Token is 121. The identity may only contain alpha-numeric and underscore characters. Other characters, including spaces, or exceeding the maximum number of characters, will result in not being able to place or receive calls.

Initiate a Basic Video Client​

const videoClient = new Video({
accountSid: "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
identity: "FIXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
});

To see all of the possible properties, see the Config interface section.

Hierarchy​

  • SDKEvent<Video.EventNames>

    ↳ Video

Accessors​

client​

• get client(): __module

Returns the underlaying Twilio SDK Client for advanced configuration and usage

    console.info(videoClient.client.Logger.getLevel())

Returns​

__module


isSupported​

• get isSupported(): boolean

Returns if Video Calling is Supported in the current Browser / Context

    console.info(videoClient.isSupported)

Returns​

boolean


localTracks​

• get localTracks(): LocalTrack[]

Returns the underlaying Twilio SDK LocalTracks for advanced configuration and usage

Returns empty Array if there is no current call

    console.info(videoClient.localTracks[0].name)

Returns​

LocalTrack[]


ready​

• get ready(): boolean

Is the videoClient ready?

    videoClient.ready ? console.info("Ready") ? console.info("Not Ready")

Returns​

boolean


room​

• get room(): null | Room

Returns the underlaying Twilio SDK Room for advanced configuration and usage

Returns null if there is no current call

    console.info(videoClient.room?.isRecording)

Returns​

null | Room

Methods​

connect​

▸ connect(Payload?): Promise<void>

Make WebRTC Video Call

 videoClient.connect({
localMediaContainer: "LocalVideoMedia",
remoteMediaContainer: "RemoteVideoMedia"
});

Parameters​

NameType
PayloadCreateRoomPayload

Returns​

Promise<void>


disconnect​

▸ disconnect(): Room

Disconnect Current Call

 videoClient.disconnect();

Returns​

Room


flipCamera​

▸ flipCamera(): Promise<void>

Flip Local Track Camera Device

 await videoClient.flipCamera();

Returns​

Promise<void>


getLocalAudioTrack​

▸ getLocalAudioTrack(«destructured»): Promise<LocalAudioTrack>

Get Local Audio Track

 const localAudio = async videoClient.getLocalAudioTrack();

Parameters​

NameType
«destructured»LocalAudioTrackOptions

Returns​

Promise<LocalAudioTrack>

Promise Containing Local Audio Track


getLocalTracks​

▸ getLocalTracks(«destructured»): Promise<LocalTrack[]>

Get Local Audio Track

 const localTracks = async videoClient.getLocalTracks();

Parameters​

NameType
«destructured»LocalTrackOptions

Returns​

Promise<LocalTrack[]>

Promise Containing Local Tracks


getLocalVideoTrack​

▸ getLocalVideoTrack(«destructured»): Promise<LocalVideoTrack>

Get Local Video Track

 const localVideo = async videoClient.getLocalVideoTrack();

Parameters​

NameType
«destructured»LocalVideoTrackOptions

Returns​

Promise<LocalVideoTrack>

Promise Containing Local Video Track


isFlipCameraSupported​

▸ isFlipCameraSupported(): boolean

Checks if Flip Camera is Supported by the Device and Current Call.

Returns false if no "Local Video Track" is Published

 const isSupported = videoClient.isFlipCameraSupported();

Returns​

boolean


mute​

▸ mute(): void

Mute Local Audio

 videoClient.mute();

Returns​

void


startScreenShare​

▸ startScreenShare(): Promise<void | LocalVideoTrack>

Start Screen Share

 await videoClient.startScreenShare();

Returns​

Promise<void | LocalVideoTrack>


stopScreenShare​

▸ stopScreenShare(): Promise<void>

Stop Screen Share

 await videoClient.stopScreenShare();

Returns​

Promise<void>


unmute​

▸ unmute(): void

UnMute Local Audio

 videoClient.unmute();

Returns​

void


updateToken​

▸ updateToken(newToken): void

Manually update Race Authentication Token

    videoClient.on("video#tokenAboutToExpire", () => {
// Get New Token
videoClient.updateToken(newToken);
});

Parameters​

NameType
newTokenstring

Returns​

void


getDeviceInfo​

▸ Static getDeviceInfo(): Promise<DeviceInfo>

Get Available Input and Output Devices

    const devices = await Video.getDeviceInfo();

Returns​

Promise<DeviceInfo>

Device Info for Available Devices