This page provides a reference to Gruveo's JavaScript Embed API, listing the events and functions exposed by the Gruveo embed.
Gruveo.Embed.generateRandomCode():String
Gruveo.Embed
After you have constructed a Gruveo.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):Gruveo.Embed
embed.call(code:String, video:Boolean, [record:Boolean], [layout:String]):Gruveo.Embed
code
, which can be a room name or a Gruveo handle. The video
parameter specifies a video call if true
and a voice one if false
. Pass true
in the optional record
parameter to automatically start call recording once the call is established. The optional layout
parameter lets you specify the layout of the recording. The following layout
values are supported:maximized
(default) – maximize the currently active speakertiled
– display all participants’ pictures in tiles of approximately the same size.embed.end():Gruveo.Embed
embed.toggleVideo(video:Boolean|String):Gruveo.Embed
video
parameter:camera
- turn on the camerascreen
- start screen sharingfalse
(Boolean) - turn outgoing video off.embed.toggleAudio(audio:Boolean):Gruveo.Embed
true
in the audio
parameter to unmute the mic or pass false
to mute it.embed.toggleRecording(record:Boolean, [layout:String]):Gruveo.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):Gruveo.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():Gruveo.Embed
embed.getSnapshot(includeSelf:Boolean):Gruveo.Embed
snapshot
event (see below) with the snapshot images. Pass true
in the includeSelf
parameter to also include a snapshot of the local video.embed.toggleFullscreen(fullscreen:Boolean):Gruveo.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):Gruveo.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 Gruveo.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_HANDLE_UNREACHABLE
- the callee is unreachableERROR_HANDLE_NONEXIST
- the Gruveo handle doesn’t existERROR_HANDLE_BUSY
- the callee is busy with another callERROR_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 or handle to call.event.details
- error details, available only for the ERROR_MEDIA
error.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 sharingextension-pending
- the Chrome screen sharing extension is being initializedextension-outdated
- the Chrome screen sharing extension need to be updated to the latest versionextension-missing
- the Chrome screen sharing extension is missingextension-unknown-state
- unknown state of the Chrome screen sharing extensionavailable
- 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
busy
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).snapshot
embed.getSnapshot()
method (see above). The event
object passed to the event handler has the following properties:event.images
- array of the participants' video snapshots. If true
was passed for includeSelf
when calling embed.getSnapshot()
, then the first element in the array will be the local video snapshot. If a particular participant is audio-only, then the corresponding array item will be undefined
.embed.getSnapshot()
method and the corresponding snapshot
event.record
and layout
parameters to the embed.call()
method.event.details
for the ERROR_MEDIA
error.layout
parameter to the embed.toggleRecording()
method.embed.toggleFullscreen()
method, the fullscreenStateChange
event and the ERROR_FULLSCREEN
error.embed.toggleVideo()
method as well as the screenSharingAvailability
and streamStateChange
events.plugin-needed
state in the error
event.error
event.error
event.recordingFilename
event.toggleRecording()
method.recordingStateChange
event.toggleRoomLock()
and switchCamera()
methods.roomLock
event.Gruveo.Embed.generateRandomCode()
global function.clientid
parameter has been added to the API signing schema.callInit
, busy
and hangup
API events have been added to allow for better tracking of user interaction with the Gruveo embed.toggleVideo()
and toggleAudio()
API methods allow for muting or unmuting the camera and the microphone, respectively.streamStateChange
event is fired whenever the camera and/or the microphone gets muted or unmuted.