Video Call

The Methods below are available for Video Call:

Method Description
sendAVChatRequest Allows logged-in user to initiate a video call
cancelAVChatRequest Allows logged-in user to cancel the initiated video call
acceptAVChatRequest Allows logged-in user to accept incoming video call
rejectAVChatRequest Allows logged-in user to reject incoming video call
startAVChatCall Starts the video call in a provided UI container
endAVChatCall Ends the video call
sendNoAnswerCall Sends no answer to the initiator of the call if callee doesn’t accept or reject the call
sendBusyTone Sends busy tone to inform the caller that callee is currently busy
muteAudio Allows logged in user to mute/unmute his audio
switchSpeakers Allows logged-in user to switch the speaker
pauseVideo Allows logged in user to turn off/on his video
toggleCamera Allows logged-in user to switch the camera

Initially, follow the steps mentioned in Initialization section to obtain an instantiated object of the CometChat class. Then use the object to call the methods required to implement the Video Call feature.

sendAVChatRequest

Allows logged-in user to initiate an video call
Method Signature:

sendAVChatRequest(String userId, Callbacks callback )

Example:

cometChat.sendAVChatRequest("15", new Callbacks() {
    @Override
    public void successCallback(JSONObject response){ /* Code Block */ }

    @Override
    public void failCallback(JSONObject response){ /* Code Block */ }
});

Arguments:

Argument Description
toId userId of a callee
callback success and failure callbacks

Response for successCallback:

{
    "id": "15",
    "callid": "bf1e7055f8e15d6f8662c7c4b6f8adb9"
}

Description:

Response Property Description
id userId of a callee
callId id of the call session

cancelAVChatRequest

Allows logged-in user to cancel the initiated video call
Method Signature:

cancelAVChatRequest(String userId, Callbacks callback )

Example:

cometChat.cancelAVChatRequest("15", new Callbacks() {
    @Override
    public void successCallback(JSONObject response){ /* Code Block */ }

    @Override
    public void failCallback(JSONObject response){ /* Code Block */ }
});

Arguments:

Argument Description
userId id of a callee
callback success and failure callbacks

Response for successCallback:

{
    "id":"15"
}

Description:

Response Property Description
id userId of a callee

acceptAVChatRequest

Allows logged-in user to accept incoming video call
Method Signature:

acceptAVChatRequest(String userId, Callbacks callback )

Example:

cometChat.acceptAVChatRequest("15", new Callbacks() {
    @Override
    public void successCallback(JSONObject response){ /* Code Block */ }

    @Override
    public void failCallback(JSONObject response){ /* Code Block */ }
});

Arguments:

Argument Description
userId userId of a caller
callback success and failure callbacks

Response for successCallback:

{
    "id":"16"
}

Description:

Response Property Description
id userId of a caller

rejectAVChatRequest

Allows logged-in user to reject incoming video call

rejectAVChatRequest(String userId, Callbacks callback )

Example:

cometChat.rejectAVChatRequest("15", new Callbacks() {
    @Override
    public void successCallback(JSONObject response){ /* Code Block */ }

    @Override
    public void failCallback(JSONObject response){ /* Code Block */ }
});

Agruments:

Argument Description
userId userId of a caller
callId id of a call received in onAvchatMessageReceived() callback
callback success and failure callbacks

Response for successCallback:

    { 
        "id":"16"
    }

Description:

Response Property Description
id userId of a caller

startAVChatCall

Starts the video call in a provided UI container
Method Signature:

startAVChatCall(Context context, String callid , RelativeLayout container, Callbacks callbacks)

Example:

cometChat.startAVChatCall(MainActivity.this, "bf1e7055f8e15d6f8662c7c4b6f8adb9", container, new Callbacks(){

    @Override
    public void failCallback(JSONObject response){ /* Code Block */ }
});

Arguments:

Argument Description
activity instance of the activity
callId id of a call received in onAvchatMessageReceived() callback
container UI container to hold AV Call UI
callback failure callbacks

endAVChatCall

Ends the video call Method Signature:

endAVChatCall(String userId, Callbacks callback )

Example:

cometChat.endAVChatCall("15", new Callbacks() {
    @Override
    public void successCallback(JSONObject response){ /* Code Block */ }

    @Override
    public void failCallback(JSONObject response){ /* Code Block */ }
});

Arguments:

Argument Description
userId userId of other chat participant
callId id of a call received in onAvchatMessageReceived() callback
callback success and failure callbacks

Response for successCallback:

{ 
    "id": "15"
}

Description:

Response Property Description
id userId of other chat participant

sendNoAnswerCall

Sends no answer to the initiator of the call if callee doesn’t accept or reject the call
Method Signature:

sendNoAnswerCall(String userId, Callbacks callback)

Example:

cometChat.sendNoAnswerCall("15", new Callbacks(){
    @Override
    public void successCallback(JSONObject response){ /* Code Block */ }

    @Override
    public void failCallback(JSONObject response){ /* Code Block */ }
});

Arguments:

Argument Description
userId id of a group to delete
callback success and failure callbacks

Response for successCallback:

{ 
    "id": "15"
}

Description:

Response Property Description
id userId of the caller

sendBusyTone

Sends busy tone to inform the caller that callee is currently busy
Method Signature:

sendBusyTone(String userId, Callbacks callback)

Example:

cometChat.sendBusyTone("15", new Callbacks(){
    @Override
    public void successCallback(JSONObject response){ /* Code Block */ }

    @Override
    public void failCallback(JSONObject response){ /* Code Block */ }
});

Arguments:

Argument Description
userId id of a group to delete
callback success and failure callbacks

Response for successCallback:

{ 
    "id": "15"
}

Description:

Response Property Description
id userId of the caller

muteAudio

Allows logged in user to mute/unmute the audio
Method Signature:

muteAudio(Boolean flag)

Example:

cometChat.muteAudio(true);

Arguments:

Argument Description
flag turn audio on/off

switchSpeakers

Allows logged-in user to switch the speaker
Method Signature:

switchSpeakers()

Example:

cometChat.switchSpeakers();

pauseVideo

Allows logged in user to pause/unpause the video
Method Signature:

pauseVideo(Boolean flag)

Example:

cometChat.pauseVideo(true);

Arguments:

Argument Description
flag turn video on/off

toggleCamera

Allows logged-in user to switch the camera
Method Signature:

toggleCamera()

Example:

cometChat.toggleCamera();

  • Was this helpful?
  • Yes   No