feat(iframe_api): get number of participants
This commit is contained in:
parent
f6fdd3ce70
commit
6bf0f9b2ec
|
@ -202,6 +202,11 @@ If you want to remove more than one event you can use ```removeEventListeners```
|
|||
api.removeEventListeners(["incomingMessage", "outgoingMessageListener"]);
|
||||
```
|
||||
|
||||
You can get the number of participants in the conference with the following code:
|
||||
```
|
||||
var numberOfParticipants = api.getNumberOfParticipant();
|
||||
```
|
||||
|
||||
You can remove the embedded Jitsi Meet Conference with the following code:
|
||||
```
|
||||
api.dispose()
|
||||
|
|
|
@ -85,6 +85,18 @@ function changeEventStatus(postis, event, status) {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds given number to the numberOfParticipants property of given APIInstance.
|
||||
* @param {JitsiMeetExternalAPI} APIInstance the instance of the
|
||||
* JitsiMeetExternalAPI
|
||||
* @param {int} number - the number of participants to be added to
|
||||
* numberOfParticipants property (this parameter can be negative number if the
|
||||
* numberOfParticipants should be decreased).
|
||||
*/
|
||||
function changeParticipantNumber(APIInstance, number) {
|
||||
APIInstance.numberOfParticipants += number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs new API instance. Creates iframe element that loads
|
||||
* Jitsi Meet.
|
||||
|
@ -161,6 +173,9 @@ function JitsiMeetExternalAPI(domain, room_name, width, height, parentNode,
|
|||
|
||||
this.eventHandlers = {};
|
||||
|
||||
this.numberOfParticipants = 1;
|
||||
this._setupListeners();
|
||||
|
||||
id++;
|
||||
}
|
||||
|
||||
|
@ -346,6 +361,25 @@ JitsiMeetExternalAPI.prototype.removeEventListeners = function(events) {
|
|||
this.removeEventListener(events[i]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the number of participants in the conference.
|
||||
* NOTE: the local participant is included.
|
||||
* @returns {int} the number of participants in the conference.
|
||||
*/
|
||||
JitsiMeetExternalAPI.prototype.getNumberOfParticipant = function() {
|
||||
return this.numberOfParticipants;
|
||||
};
|
||||
|
||||
/**
|
||||
* Setups listeners that are used internally for JitsiMeetExternalAPI.
|
||||
*/
|
||||
JitsiMeetExternalAPI.prototype._setupListeners = function() {
|
||||
this.postis.listen("participant-joined",
|
||||
changeParticipantNumber.bind(null, this, 1));
|
||||
this.postis.listen("participant-left",
|
||||
changeParticipantNumber.bind(null, this, -1));
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes the listeners and removes the Jitsi Meet frame.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue