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/libs/lib-jitsi-meet.min.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
JitsiTrackError
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:
useIPv6
- boolean propertydisableAudioLevels
- boolean property. Enables/disables audio levels.disableSimulcast
- boolean property. Enables/disables simulcast.enableWindowOnErrorHandler
- boolean property (default false). Enables/disables attaching global onerror handler (window.onerror).disableThirdPartyRequests
- if true - callstats will be disabled and the callstats API won’t be included.enableAnalyticsLogging
- boolean property (default false). Enables/disables analytics logging.callStatsCustomScriptUrl
- (optional) custom url to access callstats client scriptdisableRtx
- (optional) boolean property (default to false). Enables/disable the use of RTX.disableH264
- (optional) boolean property (default to false). If enabled, strips the H.264 codec from the local SDP.preferH264
- (optional) boolean property (default to false). Enables/disable preferring the first instance of an h264 codec in an offer by moving it to the front of the codec list.JitsiMeetJS.JitsiConnection
- the JitsiConnection
constructor. You can use that to create new server connection.
JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR); ```
JitsiMeetJS.createLocalTracks(options, firePermissionPromptIsShownEvent)
- Creates the media tracks and returns them trough Promise
object. If rejected, passes JitsiTrackError
instance to catch block.
true
, JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN
will be fired when browser shows gUM permission prompt.JitsiMeetJS.createTrackVADEmitter(localAudioDeviceId, sampleRate, vadProcessor)
- Creates a TrackVADEmitter service that connects an audio track to a VAD (voice activity detection) processor in order to obtain VAD scores for individual PCM audio samples.
localAudioDeviceId
- The target local audio device.sampleRate
- Sample rate at which the emitter will operate. Possible values 256, 512, 1024, 4096, 8192, 16384. Passing other values will default to closes neighbor, i.e. Providing a value of 4096 means that the emitter will process bundles of 4096 PCM samples at a time, higher values mean longer calls, lowers values mean more calls but shorter.vadProcessor
- VAD Processors that does the actual compute on a PCM sample.The processor needs to implement the following functions:
JitsiMeetJS.enumerateDevices(callback)
- DEPRECATED. Use JitsiMeetJS.mediaDevices.enumerateDevices(callback)
instead.
JitsiMeetJS.isDeviceChangeAvailable(deviceType)
- DEPRECATED. Use JitsiMeetJS.mediaDevices.isDeviceChangeAvailable(deviceType)
instead.
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.getActiveAudioDevice()
- goes through all audio devices on the system and returns information about one that is active, i.e. has audio signal. Returns a Promise resolving to an Object with the following structure:
JitsiMeetJS.getGlobalOnErrorHandler()
- returns function that can be used to be attached to window.onerror and if options.enableWindowOnErrorHandler is enabled returns the function used by the lib. (function(message, source, lineno, colno, error)).
JitsiMeetJS.mediaDevices
- JS object that contains methods for interaction with media devices. Following methods are available:
isDeviceListAvailable()
- returns true if retrieving the device list is supported and false - otherwiseisDeviceChangeAvailable(deviceType)
- returns true if changing the input (camera / microphone) or output (audio) device is supported and false if not. deviceType
is a type of device to change. Undefined or ‘input’ stands for input devices, ‘output’ - for audio output devices.enumerateDevices(callback)
- returns list of the available devices as a parameter to the callback function. Every device is a MediaDeviceInfo object with the following properties:
setAudioOutputDevice(deviceId)
- sets current audio output device. deviceId
- id of ‘audiooutput’ device from JitsiMeetJS.enumerateDevices()
, “ is for default device.getAudioOutputDevice()
- returns currently used audio output device id, “ stands for default device.isDevicePermissionGranted(type)
- returns a Promise which resolves to true if user granted permission to media devices. type
- ‘audio’, ‘video’ or undefined
. In case of undefined
will check if both audio and video permissions were granted.addEventListener(event, handler)
- attaches an event handler.removeEventListener(event, handler)
- removes an event handler.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
JitsiMeetJS.connectionQuality.LOCAL_STATS_UPDATED
instead.connection
detection
track
dispose()
method is called or for other reasons.mediaDevices
connectionQuality
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 three error types - connection, conference and track. 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 errors:
JitsiMeetJS.errorTypes
- constructors for Error instances that can be produced by library. Are useful for checks like error instanceof JitsiMeetJS.errorTypes.JitsiTrackError
. Following Errors are available:
JitsiTrackError
- Error that happened to a JitsiTrack.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
connect(options) - establish server connection
id
and password
properties.disconnect() - destroys the server connection
initJitsiConference(name, options) - creates new JitsiConference
object.
options - JS object with configuration options for the conference. You can change the following properties there:
NOTE: if 4 and 5 are set the library is going to send events to callstats. Otherwise the callstats integration will be disabled.
addEventListener(event, listener) - Subscribes the passed listener to the event.
JitsiMeetJS.events.connection
object.removeEventListener(event, listener) - Removes event listener.
addFeature - Adds new feature to the list of supported features for the local participant
removeFeature - Removes a feature from the list of supported features for the local participant
The object represents a conference. We have the following methods to control the conference:
join(password) - Joins the conference
leave() - leaves the conference. Returns Promise.
myUserId() - get local user ID.
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 in order to receive higher video quality (if simulcast is enabled).
Throws NetworkError or InvalidStateError or Error if the operation fails.
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. Throws an error if adding second video stream. Returns Promise.
removeTrack(track) - Removes JitsiLocalTrack object to the conference. Returns Promise.
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
setStartMutedPolicy(policy) - make all new participants join with muted audio/video
Note: available only for moderator
getStartMutedPolicy() - returns the current policy with JS object:
isStartAudioMuted() - check if audio is muted on join
isStartVideoMuted() - check if video is muted on join
sendFeedback(overallFeedback, detailedFeedback) - Sends the given feedback through CallStats if enabled.
setSubject(subject) - change subject of the conference
Note: available only for moderator
sendEndpointMessage(to, payload) - Sends message via the data channels.
Throws NetworkError or InvalidStateError or Error if the operation fails.
Throws NetworkError or InvalidStateError or Error if the operation fails.
Throws NetworkError or InvalidStateError or Error if the operation fails.
setReceiverVideoConstraint(resolution) - set the desired resolution to get from JVB (180, 360, 720, 1080, etc). You should use that method if you are using simulcast.
setSenderVideoConstraint(resolution) - set the desired resolution to send to JVB or the peer (180, 360, 720).
isHidden - checks if local user has joined as a “hidden” user. This is a specialized role used for integrations.
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. Returns Promise.
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.
dispose() - disposes the track. If the track is added to a conference the track will be removed. Returns Promise.
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.
setAudioOutput(audioOutputDeviceId) - sets new audio output device for track’s DOM elements. Video tracks are ignored.
getDeviceId() - returns device ID associated with track (for local tracks only)
isEnded() - returns true if track is ended
setEffect(effect) - Applies the effect by swapping out the existing MediaStream on the JitsiTrack with the new
MediaStream which has the desired effect. “undefined” is passed to this function for removing the effect and for
restoring the original MediaStream on the JitsiTrack.
The following methods have to be defined for the effect instance.
startEffect() - Starts the effect and returns a new MediaStream that is to be swapped with the existing one.
stopEffect() - Stops the effect.
isEnabled() - Checks if the local track supports the effect.
Note: This method is implemented only for the local tracks.
The object represents error that happened to a JitsiTrack. Is inherited from JavaScript base Error
object,
so "name"
, "message"
and "stack"
properties are available. For GUM-related errors,
exposes additional "gum"
property, which is an object with following properties:
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.