You can use Jitsi Meet API to create Jitsi Meet video conferences with custom GUI.
To embed Jitsi Meet API in your application you need to add Jitsi Meet API library
<script src="https://meet.jit.si/lib-jitsi-meet.js"></script>
Now you can access Jitsi Meet API trough the JitsiMeetJS
global object.
Jitsi Meet API has the following components:
JitsiMeetJS
JitsiConnection
JitsiConference
JitsiTrack
You can access the following methods and objects trough JitsiMeetJS
object.
JitsiMeetJS.init(options)
- this method initialized Jitsi Meet API.
The options
parameter is JS object with the following properties:
JitsiMeetJS.JitsiConnection
- the JitsiConnection
constructor. You can use that to create new server connection.
JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR); ```
JitsiMeetJS.createLocalTracks(options)
- Creates the media tracks and returns them trough Promise
object.
JitsiMeetJS.enumerateDevices(callback)
- returns list of the available devices as a parameter to the callback function. Every device is a object with the following format:
JitsiMeetJS.isDeviceListAvailable()
- returns true if retrieving the device list is support and false - otherwise.
JitsiMeetJS.isDesktopSharingEnabled()
- returns true if desktop sharing is supported and false otherwise. NOTE: that method can be used after JitsiMeetJS.init(options)
is completed otherwise the result will be always null.
JitsiMeetJS.events
- JS object that contains all events used by the API. You will need that JS object when you try to subscribe for connection or conference events.
We have two event types - connection and conference. You can access the events with the following code JitsiMeetJS.events.<event_type>.<event_name>
.
For example if you want to use the conference event that is fired when somebody leave conference you can use the following code - JitsiMeetJS.events.conference.USER_LEFT
.
We support the following events:
conference
connection
JitsiMeetJS.errors
- JS object that contains all errors used by the API. You can use that object to check the reported errors from the API
We have two error types - connection and conference. You can access the events with the following code JitsiMeetJS.errors.<error_type>.<error_name>
.
For example if you want to use the conference event that is fired when somebody leave conference you can use the following code - JitsiMeetJS.errors.conference.PASSWORD_REQUIRED
.
We support the following events:
JitsiMeetJS.logLevels
- object with the log levels:
This objects represents the server connection. You can create new JitsiConnection
object with the constructor JitsiMeetJS.JitsiConnection
. JitsiConnection
has the following methods:
JitsiConnection(appID, token, options)
- constructor. Creates the conference object.
null
null
connect(options) - establish server connection
id
and password
properties.disconnect() - destroys the server connection
initJitsiConference(name, options) - creates new JitsiConference
object.
addEventListener(event, listener) - Subscribes the passed listener to the event.
JitsiMeetJS.events.connection
object.removeEventListener(event, listener) - Removes event listener.
The object represents a conference. We have the following methods to control the conference:
join(password) - Joins the conference
leave() - leaves the conference
getLocalTracks() - Returns array with JitsiTrack objects for the local streams.
addEventListener(event, listener) - Subscribes the passed listener to the event.
JitsiMeetJS.events.conference
object.removeEventListener(event, listener) - Removes event listener.
on(event, listener) - alias for addEventListener
off(event, listener) - alias for removeEventListener
sendTextMessage(text) - sends the given string to other participants in the conference.
setDisplayName(name) - changes the display name of the local participant.
selectParticipant(participantID) - Elects the participant with the given id to be the selected participant or the speaker. You should use that method if you are using simulcast.
sendCommand(name, values) - sends user defined system command to the other participants
values - JS object. The object has the following structure:
{
value: the_value_of_the_command,
attributes: {},// map with keys the name of the attribute and values - the values of the attributes.
children: [] // array with JS object with the same structure.
}
NOTE: When you use that method the passed object will be added in every system message that is sent to the other participants. It might be sent more than once.
sendCommandOnce(name, values) - Sends only one time a user defined system command to the other participants
removeCommand(name) - removes a command for the list of the commands that are sent to the ther participants
addCommandListener(command, handler) - adds listener
removeCommandListener(command) - removes the listeners for the specified command
addTrack(track) - Adds JitsiLocalTrack object to the conference.
removeTrack(track) - Removes JitsiLocalTrack object to the conference.
isDTMFSupported() - Check if at least one user supports DTMF.
getRole() - returns string with the local user role (“moderator” or “none”)
isModerator() - checks if local user has “moderator” role
lock(password) - set password for the conference; returns Promise
Note: available only for moderator
unlock() - unset conference password; returns Promise
Note: available only for moderator
kick(id) - Kick participant from the conference
setStartMuted(audioMuted, videoMuted) - make all new participants join with muted audio/video
Note: available only for moderator
isStartAudioMuted() - check if audio is muted on join
isStartVideoMuted() - check if video is muted on join
The object represents single track - video or audio. They can be remote tracks ( from the other participants in the call) or local tracks (from the devices of the local participant). We have the following methods for controling the tracks:
getType() - returns string with the type of the track( “video” for the video tracks and “audio” for the audio tracks)
mute() - mutes the track.
Note: This method is implemented only for the local tracks.
Note: This method is implemented only for the local tracks.
isMuted() - check if track is muted
attach(container) - attaches the track to the given container.
detach(container) - removes the track from the container.
stop() - stop sending the track to the other participants in the conference.
Note: This method is implemented only for the local tracks.
getId() - returns unique string for the track.
getParticipantId() - returns id(string) of the track owner
Note: This method is implemented only for the remote tracks.
JitsiMeetJS
object:JitsiMeetJS.init();
var connection = new JitsiMeetJS.JitsiConnection(null, null, options);
connection.addEventListener(JitsiMeetJS.events.connection.CONNECTION_ESTABLISHED, onConnectionSuccess);
connection.addEventListener(JitsiMeetJS.events.connection.CONNECTION_FAILED, onConnectionFailed);
connection.addEventListener(JitsiMeetJS.events.connection.CONNECTION_DISCONNECTED, disconnect);
connection.connect();
CONNECTION_ESTABLISHED
event you are to create the JitsiConference
object and
also you may want to attach listeners for conference events (we are going to add handlers for remote track, conference joined, etc. ):
room = connection.initJitsiConference("conference1", confOptions);
room.on(JitsiMeetJS.events.conference.TRACK_ADDED, onRemoteTrack);
room.on(JitsiMeetJS.events.conference.CONFERENCE_JOINED, onConferenceJoined);
javascript
JitsiMeetJS.createLocalTracks().then(onLocalTracks);
NOTE: Adding listeners and creating local streams are not mandatory steps.
room.join();
After that step you are in the conference. Now you can continue with adding some code that will handle the events and manage the conference.