Permalink
Switch branches/tags
stable/jitsi-meet_3229 stable/jitsi-meet_3135 stable/jitsi-meet_2988 jitsi-meet_3293 jitsi-meet_3292 jitsi-meet_3291 jitsi-meet_3290 jitsi-meet_3289 jitsi-meet_3288 jitsi-meet_3287 jitsi-meet_3286 jitsi-meet_3285 jitsi-meet_3284 jitsi-meet_3283 jitsi-meet_3282 jitsi-meet_3281 jitsi-meet_3280 jitsi-meet_3279 jitsi-meet_3278 jitsi-meet_3277 jitsi-meet_3276 jitsi-meet_3275 jitsi-meet_3274 jitsi-meet_3273 jitsi-meet_3272 jitsi-meet_3271 jitsi-meet_3270 jitsi-meet_3269 jitsi-meet_3268 jitsi-meet_3267 jitsi-meet_3266 jitsi-meet_3265 jitsi-meet_3264 jitsi-meet_3263 jitsi-meet_3262 jitsi-meet_3261 jitsi-meet_3260 jitsi-meet_3259 jitsi-meet_3258 jitsi-meet_3257 jitsi-meet_3256 jitsi-meet_3255 jitsi-meet_3254 jitsi-meet_3253 jitsi-meet_3252 jitsi-meet_3251 jitsi-meet_3250 jitsi-meet_3249 jitsi-meet_3248 jitsi-meet_3247 jitsi-meet_3246 jitsi-meet_3245 jitsi-meet_3244 jitsi-meet_3243 jitsi-meet_3242 jitsi-meet_3241 jitsi-meet_3240 jitsi-meet_3239 jitsi-meet_3238 jitsi-meet_3237 jitsi-meet_3236 jitsi-meet_3235 jitsi-meet_3234 jitsi-meet_3233 jitsi-meet_3232 jitsi-meet_3231 jitsi-meet_3230 jitsi-meet_3229 jitsi-meet_3228 jitsi-meet_3227 jitsi-meet_3226 jitsi-meet_3225 jitsi-meet_3224 jitsi-meet_3223 jitsi-meet_3222 jitsi-meet_3221 jitsi-meet_3220 jitsi-meet_3219 jitsi-meet_3218 jitsi-meet_3217 jitsi-meet_3216 jitsi-meet_3215 jitsi-meet_3214 jitsi-meet_3213 jitsi-meet_3212 jitsi-meet_3211 jitsi-meet_3210 jitsi-meet_3209 jitsi-meet_3208 jitsi-meet_3207 jitsi-meet_3206 jitsi-meet_3205 jitsi-meet_3204 jitsi-meet_3203 jitsi-meet_3202 jitsi-meet_3201 jitsi-meet_3200 jitsi-meet_3199 jitsi-meet_3198 jitsi-meet_3197
Nothing to show
Find file Copy path
360 lines (296 sloc) 12.1 KB

Jitsi Meet API

You can use the Jitsi Meet API to embed Jitsi Meet in to your application.

Installation

To embed Jitsi Meet in your application you need to add the Jitsi Meet API library:

<script src="https://meet.jit.si/external_api.js"></script>

API

api = new JitsiMeetExternalAPI(domain, options)

The next step for embedding Jitsi Meet is to create the Jitsi Meet API object. Its constructor gets a number of options:

  • domain: domain used to build the conference URL, "meet.jit.si" for example.
  • options: object with properties - the optional arguments:
    • roomName: (optional) name of the room to join.
    • width: (optional) width for the iframe which will be created. If a number is specified it's treated as pixel units. If a string is specified the format is number followed by 'px', 'em', 'pt' or '%'.
    • height: (optional) height for the iframe which will be created. If a number is specified it's treated as pixel units. If a string is specified the format is number followed by 'px', 'em', 'pt' or '%'.
    • parentNode: (optional) HTML DOM Element where the iframe will be added as a child.
    • configOverwrite: (optional) JS object with overrides for options defined in config.js.
    • interfaceConfigOverwrite: (optional) JS object with overrides for options defined in interface_config.js.
    • noSSL: (optional, defaults to true) Boolean indicating if the server should be contacted using HTTP or HTTPS.
    • jwt: (optional) JWT token.
    • onload: (optional) handler for the iframe onload event.
    • invitees: (optional) Array of objects containing information about new participants that will be invited in the call.

Example:

var domain = "meet.jit.si";
var options = {
    roomName: "JitsiMeetAPIExample",
    width: 700,
    height: 700,
    parentNode: document.querySelector('#meet')
}
var api = new JitsiMeetExternalAPI(domain, options);

You can overwrite options set in config.js and interface_config.js. For example, to enable the filmstrip-only interface mode, you can use:

var options = {
    interfaceConfigOverwrite: {filmStripOnly: true}
};
var api = new JitsiMeetExternalAPI(domain, options);

You can also pass a jwt token to Jitsi Meet:

var options = {
   jwt: "<jwt_token>",
   noSsl: false
};
var api = new JitsiMeetExternalAPI(domain, options);

Controlling the embedded Jitsi Meet Conference

You can control the embedded Jitsi Meet conference using the JitsiMeetExternalAPI object by using executeCommand:

api.executeCommand(command, ...arguments)

The command parameter is String object with the name of the command. The following commands are currently supported:

  • displayName - Sets the display name of the local participant. This command requires one argument - the new display name to be set.
api.executeCommand('displayName', 'New Nickname');
  • toggleAudio - Mutes / unmutes the audio for the local participant. No arguments are required.
api.executeCommand('toggleAudio')
  • toggleVideo - Mutes / unmutes the video for the local participant. No arguments are required.
api.executeCommand('toggleVideo')
  • toggleFilmStrip - Hides / shows the filmstrip. No arguments are required.
api.executeCommand('toggleFilmStrip')
  • toggleChat - Hides / shows the chat. No arguments are required.
api.executeCommand('toggleChat')
  • toggleShareScreen - Starts / stops screen sharing. No arguments are required.
api.executeCommand('toggleShareScreen')
  • hangup - Hangups the call. No arguments are required.
api.executeCommand('hangup')
  • email - Changes the local email address. This command requires one argument - the new email address to be set.
api.executeCommand('email', 'example@example.com')
  • avatarUrl - Changes the local avatar URL. This command requires one argument - the new avatar URL to be set.
api.executeCommand('avatarUrl', 'https://avatars0.githubusercontent.com/u/3671647')

You can also execute multiple commands using the executeCommands method:

api.executeCommands(commands)

The commands parameter is an object with the names of the commands as keys and the arguments for the commands as values:

api.executeCommands({displayName: ['nickname'], toggleAudio: []});

You can add event listeners to the embedded Jitsi Meet using the addEventListener method. NOTE: This method still exists but it is deprecated. JitsiMeetExternalAPI class extends EventEmitter. Use EventEmitter methods (addListener or on).

api.addEventListener(event, listener)

The event parameter is a String object with the name of the event. The listener parameter is a Function object with one argument that will be notified when the event occurs with data related to the event.

The following events are currently supported:

  • avatarChanged - event notifications about avatar changes. The listener will receive an object with the following structure:
{
"id": id, // the id of the participant that changed his avatar.
"avatarURL": avatarURL // the new avatar URL.
}
  • audioAvailabilityChanged - event notifications about audio availability status changes. The listener will receive an object with the following structure:
{
"available": available // new available status - boolean
}
  • audioMuteStatusChanged - event notifications about audio mute status changes. The listener will receive an object with the following structure:
{
"muted": muted // new muted status - boolean
}
  • screenSharingStatusChanged - receives event notifications about turning on/off the local user screen sharing. The listener will receive object with the following structure:
{
"on": on //whether screen sharing is on
}
  • incomingMessage - Event notifications about incoming messages. The listener will receive an object with the following structure:
{
"from": from, // The id of the user that sent the message
"nick": nick, // the nickname of the user that sent the message
"message": txt // the text of the message
}
  • outgoingMessage - Event notifications about outgoing messages. The listener will receive an object with the following structure:
{
"message": txt // the text of the message
}
  • displayNameChange - event notifications about display name changes. The listener will receive an object with the following structure:
{
"id": id, // the id of the participant that changed his display name
"displayname": displayName // the new display name
}
  • emailChange - event notifications about email changes. The listener will receive an object with the following structure:
{
"id": id, // the id of the participant that changed his email
"email": email // the new email
}
  • participantJoined - event notifications about new participants who join the room. The listener will receive an object with the following structure:
{
"id": id, // the id of the participant
"displayName": displayName // the display name of the participant
}
  • participantLeft - event notifications about participants that leave the room. The listener will receive an object with the following structure:
{
"id": id // the id of the participant
}
  • videoConferenceJoined - event notifications fired when the local user has joined the video conference. The listener will receive an object with the following structure:
{
"roomName": room, // the room name of the conference
"id": id, // the id of the local participant
"displayName": displayName, // the display name of the local participant
"avatarURL": avatarURL // the avatar URL of the local participant
}
  • videoConferenceLeft - event notifications fired when the local user has left the video conference. The listener will receive an object with the following structure:
{
"roomName": room // the room name of the conference
}
  • videoAvailabilityChanged - event notifications about video availability status changes. The listener will receive an object with the following structure:
{
"available": available // new available status - boolean
}
  • videoMuteStatusChanged - event notifications about video mute status changes. The listener will receive an object with the following structure:
{
"muted": muted // new muted status - boolean
}
  • readyToClose - event notification fired when Jitsi Meet is ready to be closed (hangup operations are completed).

You can also add multiple event listeners by using addEventListeners. This method requires one argument of type Object. The object argument must have the names of the events as keys and the listeners of the events as values. NOTE: This method still exists but it is deprecated. JitsiMeetExternalAPI class extends EventEmitter. Use EventEmitter methods.

function incomingMessageListener(object)
{
// ...
}

function outgoingMessageListener(object)
{
// ...
}

api.addEventListeners({
    incomingMessage: incomingMessageListener,
    outgoingMessage: outgoingMessageListener})

If you want to remove a listener you can use removeEventListener method with argument the name of the event. NOTE: This method still exists but it is deprecated. JitsiMeetExternalAPI class extends EventEmitter. Use EventEmitter methods( removeListener).

api.removeEventListener("incomingMessage");

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. NOTE: This method still exists but it is deprecated. JitsiMeetExternalAPI class extends EventEmitter. Use EventEmitter methods.

api.removeEventListeners(["incomingMessage", "outgoingMessageListener"]);

You can get the number of participants in the conference with the following API function:

var numberOfParticipants = api.getNumberOfParticipants();

You can get the avatar URL of a participant in the conference with the following API function:

var avatarURL = api.getAvatarURL(participantId);

You can get the display name of a participant in the conference with the following API function:

var displayName = api.getDisplayName(participantId);

You can get the email of a participant in the conference with the following API function:

var email = api.getEmail(participantId);

You can get the iframe HTML element where Jitsi Meet is loaded with the following API function:

var iframe = api.getIFrame();

You can check whether the audio is muted with the following API function:

api.isAudioMuted().then(function(muted) {
    ...
});

You can check whether the video is muted with the following API function:

api.isVideoMuted().then(function(muted) {
    ...
});

You can check whether the audio is available with the following API function:

api.isAudioAvailable().then(function(available) {
    ...
});

You can check whether the video is available with the following API function:

api.isVideoAvailable().then(function(available) {
    ...
});

You can invite new participants to the call with the following API function:

api.invite([{...}, {...}, {...}]).then(function() {
    // success
}).catch(function() {
    // failure
});

NOTE: The format of the invitees in the array depends on the invite service used for the deployment.

You can remove the embedded Jitsi Meet Conference with the following API function:

api.dispose()

NOTE: It's a good practice to remove the conference before the page is unloaded.