Audio/Video Broadcast

To add Audio/Video Broadcast support in your application,

Include CustomUI.js in your index.html file to access the Custom UI functionality in your Cordova app

All the method calls will invoke their respective callback blocks as defined bel

To use Audio/Video broadcast functionality, you must download Audio/Video chat enabled SDK.
Note that the broadcast feature is available for One-on-One chat.
1. Sending broadcast request
Before starting broadcast, you have to send the request to another user. To send the broadcast use sendAVBroadcastRequest() function. The syntax for this function is as follows:

Customui.sendAVBroadcastRequestToUser(userID,successCallback,failCallback);

The success response will be as follows:

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

The response will contain the id of user to whom you have sent the request, and the callid which is unique id assigned for each Audio Video Broadcast call, so that there will be no cross connection.

2. Start broadcast
Once you sent the request successfully or someone has sent you the request, you can start the broadcast by using startBroadcast() function. The syntax for this function is as follows:

 Customui.startAVBroadcastWithInitiator(initiator,callID,container,successCallback,failCallback);

The description of parameters is as follows:
isInitiator: You have to specify your role in the broadcast. If you are the broadcaster so you will pass true, so your audio and video will be broadcasted, and if you are the listener of broadcast then pass false, so your audio and video will not be broadcasted, you will receive the broadcaster’s audio and video.
callid: This is the call id you get from sending the request, or in the request someone sent to you.
container: Container is the relative layout in which video will be displayed

3. Invite other users to the broadcast
You can invite other users in the broadcast going on. To do so use inviteUsersInBroadcast() function. The syntax for this function is as follows:

 Customui.inviteUser(userID,callID,successCallback,failCallback);

4. End broadcast
In order to end the broadcast use endBroadcast() function. The syntax for this fnuction is as follows:

Customui.endAVBroadcastWithUser(userID,callID,isInitiator,successCallback,failCallback);

The description for the parameters is as follows:
isInitiator: If you are broadcaster then pass true, so the broadcast will end for all the users, if you are listener then pass false, so the broadcast will not end for all the users, you will just leave the broadcast.
userid: Pass the user id of the user you are having the broadcast with.
callid: Pass the call id of this broadcast which you receive from the request you sent or the request you receive.

Not finding what you need?

The CometChat team is here to help!