Skip to main content
Version: v4

Presenter Mode

Overview

The Presenter Mode feature allows developers to create a calling service experience in which:

  1. There are one or more users who are presenting their video, audio and/or screen (Maximum 5)
  2. Viewers who are consumers of that presentation. (They cannot send their audio, video or screen streams out).
  3. The total number of presenters and viewers can go up to 100.
  4. Features such as mute/unmute audio, show/hide camera capture, recording, etc. will be enabled only for the Presenter in this mode.
  5. Other call participants will not get these features. Hence they act like passive viewers in the call.

Using this feature developers can create experiences such as:

  1. All hands calls
  2. Keynote speeches
  3. Webinars
  4. Talk shows
  5. Online classes
  6. and many more...

About this guide

This guide demonstrates how to start a presentation into an React Native application. Before you begin, we strongly recommend you read the calling setup guide.

Before starting a call session you have to generate a call token using the generateToken() method of the CometChatCalls SDK as mentioned here.

Start Presentation Session

The most important class that will be used in the implementation is the PresentationSettings class. This class allows you to set the various parameters for the Presentation Mode. In order to set the various parameters of the PresentationSettings class, you need to use the PresentationSettingsBuilder class. Below are the various options available with the PresentationSettings class.

You will need to set the User Type, There are 2 type of users in Presenter Mode, Presenter & Participant , You can set this PresentationSettingsBuilder by using the following method setIsPresenter(true/false)

A basic example of how to start a Presentation:

let presenterSettings = new CometChatCalls.PresenterSettingsBuilder()
.setIsPresenter(isPresenter)
.enableDefaultLayout(defaultLayout)
.setCallEventListener(callListener)
.build();

let htmlElement = document.getElementById("ELEMENT_ID");
CometChatCalls.joinPresentation(
callToken,
presenterSettings,
htmlElement
);

Listeners

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)

useEffect(() => {
CometChatCalls.addCallEventListener('UNIQUE_ID', {
onUserJoined: user => {
console.log("user joined:", user);
},
onUserLeft: user => {
console.log("user left:", user);
},
onUserListUpdated: userList => {
console.log("user list:", userList);
},
onCallEnded: () => {
console.log("Call ended");
},
onCallEndButtonPressed: () => {
console.log("End Call button pressed");
},
onError: error => {
console.log('Call Error: ', error);
},
onAudioModesUpdated: (audioModes) => {
console.log("audio modes:", audioModes);
},
onUserMuted: (event) => {
console.log("user muted:", event);
}
});
return ()=> CometChatCalls.removeCallEventListener('UNIQUE_ID')
}, [])

The CometChatCallsEventsListener listener provides you with the below callback methods:

Callback MethodDescription
onCallEnded()This method is called when the call is successfully ended. The call details can be obtained from the Call object provided.
onCallEndButtonPressed()This method is called when the user press end call button.
onUserJoined(user: RTCUser)This method is called when any other user joins the call. The user details can be obtained from the User object provided.
onUserLeft(user: RTCUser)This method is called when a user leaves the call. The details of the user can be obtained from the provided User object.
onUserListUpdated(users: Array<RTCUser>)This method is triggered every time a participant joins or leaves the call providing the list of users active in the call
onAudioModesUpdated(devices: Array<AudioMode>)This callback is triggered if any new audio output source is available or becomes unavailable.
onUserMuted(muteObj: RTCMutedUser)This method is triggered when a user is muted in the ongoing call.
onRecordingStarted(user: RTCUser)This method is triggered when a recording starts.
onRecordingStopped(user: RTCUser)This method is triggered when a recording stops.
onError(e: CometChatException)This method is called when there is some error in establishing the call.

Settings

The PresentationSettings class is the most important class when it comes to the implementation of the Calling feature. This is the class that allows you to customize the overall calling experience. The properties for the call/conference can be set using the PresentationSettingsBuilder class. This will eventually give you and object of the PresentationSettings class which you can pass to the joinPresentation() method to start the call.

The mandatory parameters that are required to be present for any call/conference to work are:

  1. Context - context of the activity/application
  2. RelativeLayout - A RelativeLayout object in which the calling UI is loaded.

The options available for customization of calls are:

ParameterDescription
setIsPresenter(isPresenter: boolean)If set to true user will join as the presenter.
If set to false user will join as the viewer.
enableDefaultLayout(defaultLayout: boolean)If set to true enables the default layout for handling the call operations.
If set to false it hides the button layout and just displays the Call View.
Default value = true
showEndCallButton(showEndCallButton: boolean)If set to true it displays the EndCallButton in Button Layout.
If set to false it hides the EndCallButton in Button Layout.
Default value = true
showPauseVideoButton(showPauseVideoButton: boolean)If set to true it displays the PauseVideoButton in Button Layout.
If set to false it hides the PauseVideoButton in Button Layout.
Default value = true
showMuteAudioButton(showMuteAudioButton: boolean)``If set to true it displays the MuteAudioButton in Button Layout.
If set to false it hides the MuteAudioButton in Button Layout.
Default value = true
showSwitchCameraButton(showSwitchCameraButton: boolean)``If set to true it displays the SwitchCameraButton in Button Layout.
If set to false it hides the SwitchCameraButton in Button Layout.
Default value = true
showAudioModeButton(showAudioModeButton: boolean)``If set to true it displays the AudioModeButton in Button Layout.
If set to false it hides the AudioModeButton in Button Layout.
Default value = true
setIsAudioOnlyCall(audioOnly: boolean)If set to true, the call will be strictly an audio call.
If set to false, the call will be an audio-video call.Default value = false
startWithAudioMuted(audioMuted: boolean)This ensures the call is started with the audio muted if set to true.
Default value = false
startWithVideoMuted(videoMuted: boolean)This ensures the call is started with the video paused if set to true.
Default value = false
startWithVideoMuted(videoMuted: boolean)If set to true it displays the Recording in Button Layout.
if set to false it hides the Recording in Button Layout.
Default value = false
setDefaultAudioMode(audioMode: string)This method can be used if you wish to start the call with a specific audio mode. The available options are
1. CometChatCalls.AUDIO_MODE.SPEAKER = "SPEAKER"
2. CometChatCalls.AUDIO_MODE.EARPIECE = "EARPIECE"
3. CometChatCalls.AUDIO_MODE.BLUETOOTH = "BLUETOOTH"
4. CometChatCalls.AUDIO_MODE.HEADPHONES = "HEADPHONES"
setEventListener(new CometChatCallsEventsListener())The CometChatCallsEventsListener listener provides you callbacks

In case you wish to achieve a completely customised 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: