This page provides a reference to the Videola.io JavaScript Embed API, listing the events and functions exposed by the video calling embed.
Videola.Embed.generateRandomCode():String
Videola.Embed
After you have constructed a Videola.Embed
object, you can call its methods to control the various aspects of the embed. This section describes the currently available methods.
embed.authorize(tokenHmac:String):Videola.Embed
embed.call(roomName:String, video:Boolean):Videola.Embed
roomName
parameter specifies the room name, and video
specifies a video call if true
(default) and a voice one if false
.embed.end():Videola.Embed
embed.toggleVideo(video:Boolean|String):Videola.Embed
video
parameter:
camera
– turn on the camerascreen
– start screen sharingfalse
(Boolean) – turn outgoing video off.embed.toggleAudio(audio:Boolean):Videola.Embed
true
in the audio
parameter to unmute the mic or pass false
to mute it.embed.toggleRecording(record:Boolean, [layout:String]):Videola.Embed
true
in the record
parameter to start call recording or false
to stop it. The optional layout
parameter lets you specify the layout of the recording as the recording is started. The following layout
values are supported:
maximized
(default) – maximize the currently active speakertiled
– display all participants’ pictures in tiles of approximately the same size.The recording functionality is only available when the call is ongoing. Check out Call Recording for call recording prerequisites and more information.
embed.toggleRoomLock(locked:Boolean):Videola.Embed
true
in the locked
parameter to lock the room or pass false
to unlock it. This functionality is only available when the call is ongoing.embed.switchCamera():Videola.Embed
embed.toggleFullscreen(fullscreen:Boolean):Videola.Embed
true
in the fullscreen
parameter to switch the embed to fullscreen or false
to exit fullscreen mode. Important notes:
call-setup
and call
states of the embed.ERROR_FULLSCREEN
error is triggered).embed.getState():String
on(event:String, handler:Function):Videola.Embed
event
. handler
is a reference to the function that should get called when the specified event fires. See the Events section below for a description of the different events that the embed might fire.Every method of the embed object, except for getters (i.e. methods whose name starts with get
) returns the embed object itself. This makes it possible to “chain” API method calls:
1 |
embed.on("stateChange", onStateChange).call("test", false); |
The API fires events to notify the host application about any changes to the embed. You can subscribe to events with the help of the on
method of the Videola.Embed
object.
Each event handler is passed a sole event
object whose properties may contain additional information about the event. For example, the event
object passed by the stateChange
event has the state
property that contains the new embed state.
Here is a list of the events fired by the API:
ready
ready
event if you wish to perform certain actions (e.g. start a call) as soon as the embed is ready.error
event
object passed to the event handler has the following properties:
event.error
– the error code. Can be one of the following:
ERROR_INTERNAL
– internal errorERROR_NO_CONNECTION
– lost connectionERROR_BUSY
– the call room is lockedERROR_ROOM_LIMIT_REACHED
– the room limit of 12 participants has been reachedERROR_INVALID_CREDENTIALS
– invalid token signature providedERROR_FREE_DEMO_ENDED
– the 5-minute call limit has been reached (when using the demo
client ID)ERROR_MEDIA
– error acquiring camera and/or microphoneERROR_FULLSCREEN
– error switching the embed to fullscreen modeERROR_INVALID_CODE
– invalid room name to join.stateChange
event
object passed to the event handler has the following properties:
event.state
– the new state of the embed, can be one of the following:
ready
– idle; provides the additional event.callDuration
property that contains the duration of the last call in secondsno-webrtc
– displaying a “no WebRTC support” messagepermissions-request
– prompting the user for camera/microphone permissionscall-setup
– waiting for the other party to joincall
– call in progress.requestToSignApiAuthToken
event
object passed to the event handler has the following properties:
event.token
– the token value to sign.Please see Embedding the Widget for details.
screenSharingAvailability
event
object passed to the event handler has the following properties:
event.availability
– screen sharing availability, can be one of the following:
unsupported
– the user’s browser doesn’t support outgoing screen sharingavailable
– outgoing screen sharing is available.streamStateChange
event
object passed to the event handler has the following properties:
event.audio
– the state of the microphone (true
for on and false
for off)event.video
– the state of the outgoing videoevent.videoSource
– the outgoing video source currently being used (possible values: camera
for camera and screen
for screen sharing).recordingStateChange
event
object passed to the event handler has the following properties:
event.us
– whether we are currently recording the call (true
for recording and false
for not recording)event.them
– whether one of the other call participants is recording.recordingFilename
event
object passed to the event handler has the following properties:
event.filename
– the filename of the recording.roomLockStateChange
event
object passed to the event handler has the following properties:
event.locked
– the current new lock state of the room (true
for locked and false
for unlocked).callInit
hangup
fullscreenStateChange
event
object passed to the event handler has the following properties:
event.fullscreen
– the current fullscreen state of the embed (true
for fullscreen and false
for not fullscreen).