Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(iframeAPI): implement avatar change commands

hristoterezovf7ce8d028d79
diff --git a/conference.js b/conference.js
index a1636820ad..4eade2d705 100644
--- a/conference.js
+++ b/conference.js
@@ -263,22 +263,6 @@ function createLocalTracks (options, checkForPermissionPrompt) {
'failed to create local tracks', options.devices, err);
return Promise.reject(err);
});
- }
-
-/**
- * Changes the email for the local user
- * @param email {string} the new email
- */
-function changeLocalEmail(email = '') {
- email = email.trim();
-
- if (email === APP.settings.getEmail()) {
- return;
- }
-
- APP.settings.setEmail(email);
- APP.UI.setUserEmail(room.myUserId(), email);
- sendData(commands.EMAIL, email);
}
/**
@@ -1403,7 +1387,7 @@ export default {
APP.UI.initEtherpad(value);
});
- APP.UI.addListener(UIEvents.EMAIL_CHANGED, changeLocalEmail);
+ APP.UI.addListener(UIEvents.EMAIL_CHANGED, this.changeLocalEmail);
room.addCommandListener(this.commands.defaults.EMAIL, (data, from) => {
APP.UI.setUserEmail(from, data.value);
});
@@ -1802,5 +1786,37 @@ export default {
APP.API.notifyReadyToClose();
maybeRedirectToWelcomePage(values[0]);
});
+ },
+
+ /**
+ * Changes the email for the local user
+ * @param email {string} the new email
+ */
+ changeLocalEmail(email = '') {
+ email = email.trim();
+
+ if (email === APP.settings.getEmail()) {
+ return;
+ }
+
+ APP.settings.setEmail(email);
+ APP.UI.setUserEmail(room.myUserId(), email);
+ sendData(commands.EMAIL, email);
+ },
+
+ /**
+ * Changes the avatar url for the local user
+ * @param url {string} the new url
+ */
+ changeLocalAvatarUrl(url = '') {
+ url = url.trim();
+
+ if (url === APP.settings.getAvatarUrl()) {
+ return;
+ }
+
+ APP.settings.setAvatarUrl(url);
+ APP.UI.setUserAvatarUrl(room.myUserId(), url);
+ sendData(commands.AVATAR_URL, url);
}
};
diff --git a/doc/api.md b/doc/api.md
index 5f25357150..97cbc43516 100644
--- a/doc/api.md
+++ b/doc/api.md
@@ -43,11 +43,9 @@ You can control the embedded Jitsi Meet conference using the JitsiMeetExternalAP
You can send command to Jitsi Meet conference using ```executeCommand```.
```
-api.executeCommand(command, arguments)
+api.executeCommand(command, ...arguments)
```
The ```command``` parameter is String object with the name of the command.
-The ```arguments``` parameter is array with the arguments required by the command.
-If no arguments are required by the command this parameter can be omitted or you can pass empty array.
Currently we support the following commands:
@@ -58,33 +56,43 @@ api.executeCommand('displayName', 'New Nickname');
```
* **toggleAudio** - mutes / unmutes the audio for the local participant. No arguments are required.
```
-api.executeCommand('toggleAudio', [])
+api.executeCommand('toggleAudio')
```
* **toggleVideo** - mutes / unmutes the video for the local participant. No arguments are required.
```
-api.executeCommand('toggleVideo', [])
+api.executeCommand('toggleVideo')
```
* **toggleFilmStrip** - hides / shows the film strip. No arguments are required.
```
-api.executeCommand('filmStrip', [])
+api.executeCommand('filmStrip')
```
* **toggleChat** - hides / shows the chat. No arguments are required.
```
-api.executeCommand('toggleChat', [])
+api.executeCommand('toggleChat')
```
* **toggleContactList** - hides / shows the contact list. No arguments are required.
```
-api.executeCommand('toggleContactList', [])
+api.executeCommand('toggleContactList')
```
* **toggleShareScreen** - starts / stops the screen sharing. No arguments are required.
```
-api.executeCommand('toggleShareScreen', [])
+api.executeCommand('toggleShareScreen')
```
* **hangup** - Hangups the call. No arguments are required.
```
-api.executeCommand('hangup', [])
+api.executeCommand('hangup')
+```
+
+* **email** - Hangups the call. No arguments are required.
+```
+api.executeCommand('email', '[email protected]')
+```
+
+* **avatarUrl** - Hangups the call. No arguments are required.
+```
+api.executeCommand('avatarUrl', 'avatarUrl')
```
You can also execute multiple commands using the method ```executeCommands```.
diff --git a/modules/API/API.js b/modules/API/API.js
index fdc2d14876..00c35d2b0a 100644
--- a/modules/API/API.js
+++ b/modules/API/API.js
@@ -54,10 +54,12 @@ function initCommands() {
"toggle-contact-list": APP.UI.toggleContactList,
"toggle-share-screen":
APP.conference.toggleScreenSharing.bind(APP.conference),
- "video-hangup": () => APP.conference.hangup()
+ "video-hangup": () => APP.conference.hangup(),
+ "email": APP.conference.changeLocalEmail,
+ "avatar-url": APP.conference.changeLocalAvatarUrl
};
Object.keys(commands).forEach(function (key) {
- postis.listen(key, commands[key]);
+ postis.listen(key, args => commands[key](...args));
});
}
diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js
index d74acd0ec5..2d237070bd 100644
--- a/modules/API/external/external_api.js
+++ b/modules/API/external/external_api.js
@@ -36,7 +36,9 @@ var commands = {
"toggleChat": "toggle-chat",
"toggleContactList": "toggle-contact-list",
"toggleShareScreen": "toggle-share-screen",
- "hangup": "video-hangup"
+ "hangup": "video-hangup",
+ "email": "email",
+ "avatarUrl": "avatar-url"
};
/**
@@ -174,15 +176,13 @@ function JitsiMeetExternalAPI(domain, room_name, width, height, parentNode,
* @param name the name of the command
* @param arguments array of arguments
*/
-JitsiMeetExternalAPI.prototype.executeCommand = function(name, argumentsList) {
+JitsiMeetExternalAPI.prototype.executeCommand
+= function(name, ...argumentsList) {
if(!(name in commands)) {
logger.error("Not supported command name.");
return;
}
- var argumentsArray = argumentsList;
- if (!argumentsArray)
- argumentsArray = [];
- sendMessage(this.postis, {method: commands[name], params: argumentsArray});
+ sendMessage(this.postis, {method: commands[name], params: argumentsList});
};
/**