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 below.

1. Send call request
Send Audio Video Broadcast call request to the userID specified. (Ensure that userID cannot be nil or empty)


function callbackmeth(result){

   alert(result);

}
CustomUI.sendAVBroadcastRequestToUser("5", callbackmeth);

Invocation: After audio video broadcast call request is sent successfully.
Response: Callback containing id of the user to whom audio video broadcast request has been sent.
Eg:

"success"={
  callID = 2be701b036ff9b6e3085d35049e59483;
  userID = 5;
}

2. Accept Audio/Video broadcast request
Accept Audio/Video broadcast request when INCOMING_AVBROADCAST_REQUEST message is received in the onAVChatMessageReceived callback block. (Ensure that userID & callID specified should be same as userID & callID received in INCOMING_AVBROADCAST_REQUEST message respectively. Also userID & callID cannot be nil or empty)


function callbackmeth(result){

  alert(result);

}

CustomUI.acceptAVBroadcastRequestOfUser("23","0fd97cadbe96b89763e098bf6140c71b",mycallback1);

Invocation: After sending audio video broadcast acknowledgement request successfully
Response: Callback containing success message
Eg:

"success"= {  
 success = "1";
}

3. Start audio video broadcast
Start an audio-video broadcast within the container view. This function has to be called after sending/accepting audio-video broadcast request only. (Ensure that userID & callID specified here should be the same while sending/accepting the request. Also userID & callID cannot be nil or empty)


function callbackmeth(result){

   alert(result);

}

CustomUI.startAVBroadcastWithInitiator(true,"23","2be701b036ff9b6e3085d35049e59483",callbackmeth);

Invocation: After starting audio video broadcast successfully.
Response: Callback containing success message
Eg:

"success"={  
 "Connected user" = "1";
}

The description of parameters is as follows:
initiator: 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.
userID: Pass the user id of the user you are having the broadcast with.

Sender

CustomUI.startAVBroadcastWithInitiator(true,"23","2be701b036ff9b6e3085d35049e59483",callbackmeth);;

Receiver

CustomUI.startAVBroadcastWithInitiator(false,"23","2be701b036ff9b6e3085d35049e59483",callbackmeth);;

4. End call
End audio-video broadcast with the user corresponding to userID & callID specified. (Ensure that userID & callID specified should be same as given when starting the audio-video broadcast. Also userID & callID cannot be nil or empty)


function callbackmeth(result){

   alert(result);

}

CustomUI.endAVBroadcastWithUser(true,"23","0fd97cadbe96b89763e098bf6140c71b",callbackmeth);

Invocation: After ending audio video broadcast successfully.
Response: Callback containing success message.
Eg:

"success" = {  
 success = 1;
}

The description of parameters is as follows:
initiator: 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.
callID: This is the call id you get from sending the request, or in the request someone sent to you.
userID: Pass the user id of the user you are having the broadcast with.

5. Switch between front and rear camera in a Video call


function callbackmeth(result){

   alert(result);

}

CustomUI.switchCameraAVBroadcastSDK();

Please refer ‎error codes for failure responses.

Not finding what you need?

The CometChat team is here to help!