Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(iframe_api): get number of participants
hristoterezov6bf0f9b2ecfe
diff --git a/doc/api.md b/doc/api.mdindex 97cbc43516..d691d1c8bc 100644--- a/doc/api.md+++ b/doc/api.md@@ -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()diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.jsindex 2d237070bd..bfd84930f7 100644--- a/modules/API/external/external_api.js+++ b/modules/API/external/external_api.js@@ -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.*/