|
@@ -1,17 +1,17 @@
|
1
|
|
-Jitsi Meet API
|
2
|
|
-============
|
|
1
|
+# Jitsi Meet API
|
3
|
2
|
|
4
|
|
-You can use Jitsi Meet API to embed Jitsi Meet in to your application.
|
|
3
|
+You can use the Jitsi Meet API to embed Jitsi Meet in to your application.
|
5
|
4
|
|
6
|
|
-Installation
|
7
|
|
-==========
|
|
5
|
+## Installation
|
|
6
|
+
|
|
7
|
+To embed Jitsi Meet in your application you need to add the Jitsi Meet API library:
|
8
|
8
|
|
9
|
|
-To embed Jitsi Meet in your application you need to add Jitsi Meet API library
|
10
|
9
|
```javascript
|
11
|
10
|
<script src="https://meet.jit.si/external_api.js"></script>
|
12
|
11
|
```
|
13
|
12
|
|
14
|
|
-The next step for embedding Jitsi Meet is to create the Jitsi Meet API object
|
|
13
|
+The next step for embedding Jitsi Meet is to create the Jitsi Meet API object:
|
|
14
|
+
|
15
|
15
|
```javascript
|
16
|
16
|
<script>
|
17
|
17
|
var domain = "meet.jit.si";
|
|
@@ -21,169 +21,174 @@ The next step for embedding Jitsi Meet is to create the Jitsi Meet API object
|
21
|
21
|
var api = new JitsiMeetExternalAPI(domain, room, width, height);
|
22
|
22
|
</script>
|
23
|
23
|
```
|
24
|
|
-You can paste that lines in your html code where you want to be placed the Jitsi Meet conference
|
25
|
|
-or you can specify the parent HTML element for the Jitsi Meet conference in the JitsiMeetExternalAPI
|
26
|
|
-constructor.
|
|
24
|
+
|
|
25
|
+You can use the above lines to indicate where exactly you want the Jitsi Meet conference to be placed in your HTML code,
|
|
26
|
+or you can specify the parent HTML element for the Jitsi Meet conference in the `JitsiMeetExternalAPI`
|
|
27
|
+constructor:
|
|
28
|
+
|
27
|
29
|
```javascript
|
28
|
|
- var api = new JitsiMeetExternalAPI(domain, room, width, height, htmlElement);
|
|
30
|
+var api = new JitsiMeetExternalAPI(domain, room, width, height, htmlElement);
|
29
|
31
|
```
|
30
|
|
-If you don't specify room the user will enter in new conference with random room name.
|
31
|
32
|
|
32
|
|
-You can overwrite options set in config.js and interface_config.js. For example, to enable the film-strip-only interface mode and disable simulcast, you can use:
|
|
33
|
+If you don't specify the room the user will enter in new conference with a random room name.
|
|
34
|
+
|
|
35
|
+You can overwrite options set in [config.js]() and [interface_config.js](). For example, to enable the film-strip-only interface mode and disable simulcast, you can use:
|
|
36
|
+
|
33
|
37
|
```javascript
|
34
|
|
- var configOverwrite = {enableSimulcast: false};
|
35
|
|
- var interfaceConfigOverwrite = {filmStripOnly: true};
|
36
|
|
- var api = new JitsiMeetExternalAPI(domain, room, width, height, htmlElement, configOverwrite, interfaceConfigOverwrite);
|
|
38
|
+var configOverwrite = {disableSimulcast: true};
|
|
39
|
+var interfaceConfigOverwrite = {filmStripOnly: true};
|
|
40
|
+var api = new JitsiMeetExternalAPI(domain, room, width, height, htmlElement, configOverwrite, interfaceConfigOverwrite);
|
37
|
41
|
```
|
38
|
42
|
|
39
|
|
-Controlling embedded Jitsi Meet Conference
|
40
|
|
-=========
|
|
43
|
+## Controlling the embedded Jitsi Meet Conference
|
41
|
44
|
|
42
|
|
-You can control the embedded Jitsi Meet conference using the JitsiMeetExternalAPI object.
|
|
45
|
+You can control the embedded Jitsi Meet conference using the `JitsiMeetExternalAPI` object by using `executeCommand`:
|
43
|
46
|
|
44
|
|
-You can send command to Jitsi Meet conference using ```executeCommand```.
|
45
|
|
-```
|
|
47
|
+```javascript
|
46
|
48
|
api.executeCommand(command, ...arguments)
|
47
|
49
|
```
|
48
|
|
-The ```command``` parameter is String object with the name of the command.
|
49
|
|
-Currently we support the following commands:
|
50
|
50
|
|
|
51
|
+The `command` parameter is String object with the name of the command. The following commands are currently supported:
|
51
|
52
|
|
52
|
|
-* **displayName** - sets the display name of the local participant. This command requires one argument -
|
53
|
|
-the new display name to be set
|
54
|
|
-```
|
|
53
|
+* **displayName** - Sets the display name of the local participant. This command requires one argument - the new display name to be set.
|
|
54
|
+```javascript
|
55
|
55
|
api.executeCommand('displayName', 'New Nickname');
|
56
|
56
|
```
|
57
|
|
-* **toggleAudio** - mutes / unmutes the audio for the local participant. No arguments are required.
|
58
|
|
-```
|
|
57
|
+
|
|
58
|
+* **toggleAudio** - Mutes / unmutes the audio for the local participant. No arguments are required.
|
|
59
|
+```javascript
|
59
|
60
|
api.executeCommand('toggleAudio')
|
60
|
61
|
```
|
61
|
|
-* **toggleVideo** - mutes / unmutes the video for the local participant. No arguments are required.
|
62
|
|
-```
|
|
62
|
+
|
|
63
|
+* **toggleVideo** - Mutes / unmutes the video for the local participant. No arguments are required.
|
|
64
|
+```javascript
|
63
|
65
|
api.executeCommand('toggleVideo')
|
64
|
66
|
```
|
65
|
|
-* **toggleFilmStrip** - hides / shows the film strip. No arguments are required.
|
66
|
|
-```
|
67
|
|
-api.executeCommand('filmStrip')
|
68
|
|
-```
|
69
|
|
-* **toggleChat** - hides / shows the chat. No arguments are required.
|
|
67
|
+
|
|
68
|
+* **toggleFilmStrip** - Hides / shows the film strip. No arguments are required.
|
|
69
|
+```javascript
|
|
70
|
+api.executeCommand('toggleFilmStrip')
|
70
|
71
|
```
|
|
72
|
+
|
|
73
|
+* **toggleChat** - Hides / shows the chat. No arguments are required.
|
|
74
|
+```javascript
|
71
|
75
|
api.executeCommand('toggleChat')
|
72
|
76
|
```
|
73
|
|
-* **toggleContactList** - hides / shows the contact list. No arguments are required.
|
74
|
|
-```
|
|
77
|
+
|
|
78
|
+* **toggleContactList** - Hides / shows the contact list. No arguments are required.
|
|
79
|
+```javascript
|
75
|
80
|
api.executeCommand('toggleContactList')
|
76
|
81
|
```
|
77
|
82
|
|
78
|
|
-* **toggleShareScreen** - starts / stops the screen sharing. No arguments are required.
|
79
|
|
-```
|
|
83
|
+* **toggleShareScreen** - Starts / stops screen sharing. No arguments are required.
|
|
84
|
+```javascript
|
80
|
85
|
api.executeCommand('toggleShareScreen')
|
81
|
86
|
```
|
82
|
87
|
|
83
|
88
|
* **hangup** - Hangups the call. No arguments are required.
|
84
|
|
-```
|
|
89
|
+```javascript
|
85
|
90
|
api.executeCommand('hangup')
|
86
|
91
|
```
|
87
|
92
|
|
88
|
|
-* **email** - Hangups the call. No arguments are required.
|
89
|
|
-```
|
|
93
|
+* **email** - Changes the local email address. This command requires one argument - the new email address to be set.
|
|
94
|
+```javascript
|
90
|
95
|
api.executeCommand('email', 'example@example.com')
|
91
|
96
|
```
|
92
|
97
|
|
93
|
|
-* **avatarUrl** - Hangups the call. No arguments are required.
|
94
|
|
-```
|
95
|
|
-api.executeCommand('avatarUrl', 'avatarUrl')
|
|
98
|
+* **avatarUrl** - Changes the local avatar URL. This command requires one argument - the new avatar URL to be set.
|
|
99
|
+```javascript
|
|
100
|
+api.executeCommand('avatarUrl', 'https://avatars0.githubusercontent.com/u/3671647')
|
96
|
101
|
```
|
97
|
102
|
|
98
|
|
-You can also execute multiple commands using the method ```executeCommands```.
|
99
|
|
-```
|
|
103
|
+You can also execute multiple commands using the `executeCommands` method:
|
|
104
|
+```javascript
|
100
|
105
|
api.executeCommands(commands)
|
101
|
106
|
```
|
102
|
|
-The ```commands``` parameter is object with keys the names of the commands and values the arguments for the
|
103
|
|
-commands.
|
104
|
|
-
|
105
|
|
-```
|
|
107
|
+The `commands` parameter is an object with the names of the commands as keys and the arguments for the commands asvalues:
|
|
108
|
+```javascript
|
106
|
109
|
api.executeCommands({displayName: ['nickname'], toggleAudio: []});
|
107
|
110
|
```
|
108
|
111
|
|
109
|
|
-You can add event listeners to the embedded Jitsi Meet using ```addEventListener``` method.
|
110
|
|
-```
|
|
112
|
+You can add event listeners to the embedded Jitsi Meet using the `addEventListener` method.
|
|
113
|
+```javascript
|
111
|
114
|
api.addEventListener(event, listener)
|
112
|
115
|
```
|
113
|
|
-The ```event``` parameter is String object with the name of the event.
|
114
|
|
-The ```listener``` paramenter is Function object with one argument that will be notified when the event occurs
|
115
|
|
-with data related to the event.
|
116
|
116
|
|
117
|
|
-Currently we support the following events:
|
|
117
|
+The `event` parameter is a String object with the name of the event.
|
|
118
|
+The `listener` parameter is a Function object with one argument that will be notified when the event occurs with data related to the event.
|
118
|
119
|
|
119
|
|
-* **incomingMessage** - event notifications about incoming
|
120
|
|
-messages. The listener will receive object with the following structure:
|
121
|
|
-```
|
|
120
|
+The following events are currently supported:
|
|
121
|
+
|
|
122
|
+* **incomingMessage** - Event notifications about incoming
|
|
123
|
+messages. The listener will receive an object with the following structure:
|
|
124
|
+```javascript
|
122
|
125
|
{
|
123
|
|
-"from": from,//JID of the user that sent the message
|
124
|
|
-"nick": nick,//the nickname of the user that sent the message
|
125
|
|
-"message": txt//the text of the message
|
|
126
|
+"from": from, // JID of the user that sent the message
|
|
127
|
+"nick": nick, // the nickname of the user that sent the message
|
|
128
|
+"message": txt // the text of the message
|
126
|
129
|
}
|
127
|
130
|
```
|
128
|
|
-* **outgoingMessage** - event notifications about outgoing
|
129
|
|
-messages. The listener will receive object with the following structure:
|
130
|
|
-```
|
|
131
|
+
|
|
132
|
+* **outgoingMessage** - Event notifications about outgoing
|
|
133
|
+messages. The listener will receive an object with the following structure:
|
|
134
|
+```javascript
|
131
|
135
|
{
|
132
|
|
-"message": txt//the text of the message
|
|
136
|
+"message": txt // the text of the message
|
133
|
137
|
}
|
134
|
138
|
```
|
|
139
|
+
|
135
|
140
|
* **displayNameChanged** - event notifications about display name
|
136
|
|
-change. The listener will receive object with the following structure:
|
137
|
|
-```
|
|
141
|
+changes. The listener will receive an object with the following structure:
|
|
142
|
+```javascript
|
138
|
143
|
{
|
139
|
|
-jid: jid,//the JID of the participant that changed his display name
|
140
|
|
-displayname: displayName //the new display name
|
|
144
|
+"jid": jid, // the JID of the participant that changed his display name
|
|
145
|
+"displayname": displayName // the new display name
|
141
|
146
|
}
|
142
|
147
|
```
|
143
|
|
-* **participantJoined** - event notifications about new participant.
|
144
|
|
-The listener will receive object with the following structure:
|
145
|
|
-```
|
|
148
|
+
|
|
149
|
+* **participantJoined** - event notifications about new participants who join the room. The listener will receive an object with the following structure:
|
|
150
|
+```javascript
|
146
|
151
|
{
|
147
|
|
-jid: jid //the jid of the participant
|
|
152
|
+"jid": jid // the JID of the participant
|
148
|
153
|
}
|
149
|
154
|
```
|
150
|
|
-* **participantLeft** - event notifications about participant that left room.
|
151
|
|
-The listener will receive object with the following structure:
|
152
|
|
-```
|
|
155
|
+
|
|
156
|
+* **participantLeft** - event notifications about participants that leave the room. The listener will receive an object with the following structure:
|
|
157
|
+```javascript
|
153
|
158
|
{
|
154
|
|
-jid: jid //the jid of the participant
|
|
159
|
+"jid": jid // the JID of the participant
|
155
|
160
|
}
|
156
|
161
|
```
|
157
|
|
-* **videoConferenceJoined** - event notifications fired when the local user has joined the video conference.
|
158
|
|
-The listener will receive object with the following structure:
|
159
|
|
-```
|
|
162
|
+
|
|
163
|
+* **videoConferenceJoined** - event notifications fired when the local user has joined the video conference. The listener will receive an object with the following structure:
|
|
164
|
+```javascript
|
160
|
165
|
{
|
161
|
|
-roomName: room //the room name of the conference
|
|
166
|
+"roomName": room // the room name of the conference
|
162
|
167
|
}
|
163
|
168
|
```
|
164
|
|
-* **videoConferenceLeft** - event notifications fired when the local user has left the video conference.
|
165
|
|
-The listener will receive object with the following structure:
|
166
|
|
-```
|
|
169
|
+
|
|
170
|
+* **videoConferenceLeft** - event notifications fired when the local user has left the video conference. The listener will receive an object with the following structure:
|
|
171
|
+```javascript
|
167
|
172
|
{
|
168
|
|
-roomName: room //the room name of the conference
|
|
173
|
+"roomName": room // the room name of the conference
|
169
|
174
|
}
|
170
|
175
|
```
|
171
|
176
|
|
172
|
177
|
* **readyToClose** - event notification fired when Jitsi Meet is ready to be closed (hangup operations are completed).
|
173
|
178
|
|
174
|
|
-You can also add multiple event listeners by using ```addEventListeners```.
|
|
179
|
+You can also add multiple event listeners by using `addEventListeners`.
|
175
|
180
|
This method requires one argument of type Object. The object argument must
|
176
|
|
-have keys with the names of the events and values the listeners of the events.
|
|
181
|
+have the names of the events as keys and the listeners of the events as values.
|
177
|
182
|
|
178
|
|
-```
|
|
183
|
+```javascript
|
179
|
184
|
function incomingMessageListener(object)
|
180
|
185
|
{
|
181
|
|
-...
|
|
186
|
+// ...
|
182
|
187
|
}
|
183
|
188
|
|
184
|
189
|
function outgoingMessageListener(object)
|
185
|
190
|
{
|
186
|
|
-...
|
|
191
|
+// ...
|
187
|
192
|
}
|
188
|
193
|
|
189
|
194
|
api.addEventListeners({
|
|
@@ -191,25 +196,28 @@ api.addEventListeners({
|
191
|
196
|
outgoingMessage: outgoingMessageListener})
|
192
|
197
|
```
|
193
|
198
|
|
194
|
|
-If you want to remove a listener you can use ```removeEventListener``` method with argument the name of the event.
|
195
|
|
-```
|
|
199
|
+If you want to remove a listener you can use `removeEventListener` method with argument the name of the event.
|
|
200
|
+
|
|
201
|
+```javascript
|
196
|
202
|
api.removeEventListener("incomingMessage");
|
197
|
203
|
```
|
198
|
204
|
|
199
|
|
-If you want to remove more than one event you can use ```removeEventListeners``` method with argument
|
200
|
|
- array with the names of the events.
|
201
|
|
-```
|
|
205
|
+If you want to remove more than one event you can use `removeEventListeners` method with an Array with the names of the events as an argument.
|
|
206
|
+```javascript
|
202
|
207
|
api.removeEventListeners(["incomingMessage", "outgoingMessageListener"]);
|
203
|
208
|
```
|
204
|
209
|
|
205
|
|
-You can get the number of participants in the conference with the following code:
|
206
|
|
-```
|
|
210
|
+You can get the number of participants in the conference with the following API function:
|
|
211
|
+```javascript
|
207
|
212
|
var numberOfParticipants = api.getNumberOfParticipants();
|
208
|
213
|
```
|
209
|
214
|
|
210
|
|
-You can remove the embedded Jitsi Meet Conference with the following code:
|
211
|
|
-```
|
|
215
|
+You can remove the embedded Jitsi Meet Conference with the following API function:
|
|
216
|
+```javascript
|
212
|
217
|
api.dispose()
|
213
|
218
|
```
|
214
|
219
|
|
215
|
|
-It is a good practice to remove the conference before the page is unloaded.
|
|
220
|
+NOTE: It's a good practice to remove the conference before the page is unloaded.
|
|
221
|
+
|
|
222
|
+[config.js]: https://github.com/jitsi/jitsi-meet/blob/master/config.js
|
|
223
|
+[interface_config.js]: https://github.com/jitsi/jitsi-meet/blob/master/interface_config.js
|