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 thegenerateToken method of CometChatCalls class.
- JavaScript
- TypeScript
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 theCallSettings 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:
- callToken: The unique token for the call/conference session.
- callSettings: The object of CallSettings class.
- htmlElement: A unique DOM element inside which call UI will be loaded.
- JavaScript
- TypeScript
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)
- JavaScript
Settings
TheCallSettings 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 themuteAudio(mute: boolean) method to mute/unmute your audio stream.
- JavaScript
- TypeScript
true the audio stream will be muted and if set to false the audio stream will be unmuted.
Pause Video
You can call thepauseVideo(pause: boolean) method to pause/unpause video stream.
- JavaScript
- TypeScript
true the video stream will be paused and if set to false the video stream will be unpaused.
Start Screen Share
You can callstartScreenShare() to start the screen share.
- JavaScript
- TypeScript
Stop Screen Share
You can callstopScreenShare() to stop the screen share.
- JavaScript
- TypeScript
Set Mode
You can use thesetMode(mode: string) method to set the mode.
- JavaScript
- TypeScript
Get Audio Input Devices
You can use thegetAudioInputDevices() method to get all the available audio input devices.
- JavaScript
- TypeScript
Get Audio Output Devices
You can use thegetAudioOutputDevices() method to get all the available audio output devices.
- JavaScript
- TypeScript
Get Video Input Devices
You can use thegetVideoInputDevices() method to get all the available video input devices.
- JavaScript
- TypeScript
Set Audio Input Device
You can use thesetAudioInputDevice(deviceId) method to set the active audio input device.
- JavaScript
- TypeScript
Set Audio Output Device
You can use thesetAudioOutputDevice(deviceId) method to set the active audio output device.
- JavaScript
- TypeScript
Set Video Input Device
You can use thesetVideoInputDevice(deviceId) method to set the active video input device.
- JavaScript
- TypeScript
Switch To Video Call
You can use theswitchToVideoCall() method to switch from audio call to video call.
- JavaScript
- TypeScript
End Call
You can use theCometChat.endCall() method of the CometChat class to end the call.
- JavaScript
- TypeScript