feat(iframeAPI): implement avatar change commands
This commit is contained in:
parent
85e5b0fc31
commit
f7ce8d028d
|
@ -263,22 +263,6 @@ function createLocalTracks (options, checkForPermissionPrompt) {
|
||||||
'failed to create local tracks', options.devices, err);
|
'failed to create local tracks', options.devices, err);
|
||||||
return Promise.reject(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.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) => {
|
room.addCommandListener(this.commands.defaults.EMAIL, (data, from) => {
|
||||||
APP.UI.setUserEmail(from, data.value);
|
APP.UI.setUserEmail(from, data.value);
|
||||||
});
|
});
|
||||||
|
@ -1802,5 +1786,37 @@ export default {
|
||||||
APP.API.notifyReadyToClose();
|
APP.API.notifyReadyToClose();
|
||||||
maybeRedirectToWelcomePage(values[0]);
|
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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
28
doc/api.md
28
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```.
|
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 ```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:
|
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.
|
* **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.
|
* **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.
|
* **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.
|
* **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.
|
* **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.
|
* **toggleShareScreen** - starts / stops the screen sharing. No arguments are required.
|
||||||
```
|
```
|
||||||
api.executeCommand('toggleShareScreen', [])
|
api.executeCommand('toggleShareScreen')
|
||||||
```
|
```
|
||||||
|
|
||||||
* **hangup** - Hangups the call. No arguments are required.
|
* **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', 'example@example.com')
|
||||||
|
```
|
||||||
|
|
||||||
|
* **avatarUrl** - Hangups the call. No arguments are required.
|
||||||
|
```
|
||||||
|
api.executeCommand('avatarUrl', 'avatarUrl')
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also execute multiple commands using the method ```executeCommands```.
|
You can also execute multiple commands using the method ```executeCommands```.
|
||||||
|
|
|
@ -54,10 +54,12 @@ function initCommands() {
|
||||||
"toggle-contact-list": APP.UI.toggleContactList,
|
"toggle-contact-list": APP.UI.toggleContactList,
|
||||||
"toggle-share-screen":
|
"toggle-share-screen":
|
||||||
APP.conference.toggleScreenSharing.bind(APP.conference),
|
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) {
|
Object.keys(commands).forEach(function (key) {
|
||||||
postis.listen(key, commands[key]);
|
postis.listen(key, args => commands[key](...args));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,9 @@ var commands = {
|
||||||
"toggleChat": "toggle-chat",
|
"toggleChat": "toggle-chat",
|
||||||
"toggleContactList": "toggle-contact-list",
|
"toggleContactList": "toggle-contact-list",
|
||||||
"toggleShareScreen": "toggle-share-screen",
|
"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 name the name of the command
|
||||||
* @param arguments array of arguments
|
* @param arguments array of arguments
|
||||||
*/
|
*/
|
||||||
JitsiMeetExternalAPI.prototype.executeCommand = function(name, argumentsList) {
|
JitsiMeetExternalAPI.prototype.executeCommand
|
||||||
|
= function(name, ...argumentsList) {
|
||||||
if(!(name in commands)) {
|
if(!(name in commands)) {
|
||||||
logger.error("Not supported command name.");
|
logger.error("Not supported command name.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var argumentsArray = argumentsList;
|
sendMessage(this.postis, {method: commands[name], params: argumentsList});
|
||||||
if (!argumentsArray)
|
|
||||||
argumentsArray = [];
|
|
||||||
sendMessage(this.postis, {method: commands[name], params: argumentsArray});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue