Audio/Video Group Conference

To use Audio/Video Chat functionality, you must have downloaded Audio/Video Chat enabled SDK. To start using Group Audio/Video Chat functionality you must have Group Audio/Video Chat instance which can be obtained as follows:

GroupAVChat grpchat =  GroupAVChat.getGroupChatInstance(context)

Note that Group Audio/Video Chat works with only chatrooms, so you need to have subscribed to chatroom and have joined any chatroom.

1. Send Conference request
Before you start a conference, you need to send the conference request to the chatroom you have joined. The syntax is as follows:

sendConferenceRequest(Callbacks callback )

e.g:

grpavchat.sendConferenceRequest(new Callbacks() {
        @Override
        public void successCallback(JSONObject response) {
        }
        @Override
        public void failCallback(JSONObject response) {
        }
});

You will get success response as follows:

{ "status":"Conference request sent successfully" }

2. Join the conference
You can join the already started conference by using the function joinConference(). The syntax is as follows:

joinConference(Callbacks callback )

The success response will be as follows:

{"status":"conference join success"}

3. Start Conference
Once you have sent the request for conference or made join conference request successfully then you can start the conference. The syntax is as follows:

startConference(RelativeLayout container,Callbacks callback )

e.g:

grpavchat.startConference(container, new Callbacks() {
        @Override
        public void successCallback(JSONObject response) {	
	}
	@Override
	public void failCallback(JSONObject response) {
	}
});

Here the container is the relative layout in which video will be displayed. There is no success callback fired here.
Make sure that before calling this function you have either sent the request for conference or called the join conference function as mentioned below, else you will get error code ‘52’ with message ‘call details not found’.

4. End conference
You can leave the conference by calling endConference() function. The conference will end when all the members leave the conference. The syntax is as follows:

endConference(Callbacks callback )

5.Toggle audio
While having conference you can turn on/off audio, so that other user cannot listen your voice. For this you can use toggleAudio() function. The syntax is as follows:

toogleAudio(Boolean flag)

6. Toggle video
While having conference you can turn on/off video, so that other user cannot see your video. For this you can use toggleVideo() function. The syntax is as follows:

toogleVideo(Boolean flag)

7. Switch camera
While having a conference you can switch between your front camera and back main camera. For this you can use switchCamera() function. This function doesn’t require any parameter.

8. Rotation handling
As you know Android devices are sensitive to the rotation, you need to handle the rotation specially while having a conference, so that you don’t find any difficulties and have a smooth transition while rotating the device. You need to use the following function to do so:

removeVideoOnRotation()

and 
        
addVideoOnRotation()

e.g

@Override
protected void onPause(){ 
    super.onPause();
    grpchat.removeVideoOnRotation(layoutcontainer);
}

@Override
protected void onResume() {
    super.onResume();
    grpchat.addVideoOnRotation(layoutcontainer);
}

Pass the container which you have used in the function startConference() function.

Not finding what you need?

The CometChat team is here to help!