Skip to main content

Overview

This guide demonstrates how to start call in to an web. Before you begin, we strongly recommend you read the calling setup guide.

Generate Call Token

Prior to starting the call session, it is necessary to have a call token. A call token can be generated using the generateToken method of CometChatCalls class.
On success of generateToken method you will get the response object containing call token with key named token.

Start Call Session

The most important class that will be used in the implementation is the CallSettings class. This class allows you to set the various parameters for the call/conference. In order to set the various parameters of the CallSettings class, you need to use the CallSettingsBuilder class. Below are the various options available with the CallSettings class. The mandatory parameters that are required to be present for any call/conference to work are:
  1. callToken: The unique token for the call/conference session.
  2. callSettings: The object of CallSettings class.
  3. htmlElement: A unique DOM element inside which call UI will be loaded.
A basic example of how to start a call session:
The setIsAudioOnlyCall() method allows you to set if the call is supposed to be an audio call or an audio-video call. If set to true, the call will be an audio-only call else when set to false the call will be an audio-video call. The default is false, so if not set, the call will be an audio-video call. The OngoingCallListener listener provides you with the below callback methods:

Listener

Listeners can be added in two ways the first one is to use .setCallEventListener(listeners : OngoingCallListener) method in CallSettingsBuilder or PresenterSettingsBuilder class. The second way is to use CometChatCalls.addCallEventListener(name: string, callListener: OngoingCallListener) by this you can add multiple listeners and remove the specific listener by their name CometChatCalls.removeCallEventListener(name: string)

Settings

The CallSettings class is the most important class when it comes to the implementation of the Calling feature. This is the class that allows you to customise the overall calling experience. The properties for the call/conference can be set using the CallSettingsBuilder class. This will eventually give you an object of the CallSettings class which you can pass to the startSession() method to start the call. The options available for customisation of calls are: In case you wish to achieve a completely customized UI for the Calling experience, you can do so by embedding default android buttons to the screen as per your requirement and then use the below methods to achieve different functionalities for the embedded buttons. For the use case where you wish to align your own custom buttons and not use the default layout provided by CometChat, you can embed the buttons in your layout and use the below methods to perform the corresponding operations:

Mute Audio

You can call the muteAudio(mute: boolean) method to mute/unmute your audio stream.
If set to true the audio stream will be muted and if set to false the audio stream will be unmuted.

Pause Video

You can call the pauseVideo(pause: boolean) method to pause/unpause video stream.
If set to true the video stream will be paused and if set to false the video stream will be unpaused.

Start Screen Share

You can call startScreenShare() to start the screen share.

Stop Screen Share

You can call stopScreenShare() to stop the screen share.

Set Mode

You can use the setMode(mode: string) method to set the mode.

Get Audio Input Devices

You can use the getAudioInputDevices() method to get all the available audio input devices.

Get Audio Output Devices

You can use the getAudioOutputDevices() method to get all the available audio output devices.

Get Video Input Devices

You can use the getVideoInputDevices() method to get all the available video input devices.

Set Audio Input Device

You can use the setAudioInputDevice(deviceId) method to set the active audio input device.

Set Audio Output Device

You can use the setAudioOutputDevice(deviceId) method to set the active audio output device.

Set Video Input Device

You can use the setVideoInputDevice(deviceId) method to set the active video input device.

Switch To Video Call

You can use the switchToVideoCall() method to switch from audio call to video call.

End Call

You can use the CometChat.endCall() method of the CometChat class to end the call.