Skip to content

Latest commit

 

History

History
186 lines (149 loc) · 18.3 KB

using-the-whereby-embed-element.md

File metadata and controls

186 lines (149 loc) · 18.3 KB
description
Our web component allows you to embed Whereby's pre-built UI on any webpage. It provides a simple readable integration and exposes local client events and commands between our platform and yours.

Web Component Reference

Installation

When using React or a bundler like Webpack, Rollup, Parcel, etc

npm install @whereby.com/browser-sdk
import "@whereby.com/browser-sdk/embed"

{% tabs %} {% tab title="HTML" %} {% code overflow="wrap" %}

<whereby-embed room="https://subdomain.whereby.com/your_room?roomKey=3fe345a"></whereby-embed>

{% endcode %}

You can use a hostRoomUrl instead of the roomUrl, if you want to give the user host privileges {% endtab %}

{% tab title="JSX" %}

const MyComponent = ({ roomUrl }) => {
    return <whereby-embed room={roomUrl} />
}

export default MyComponent

You can use a hostRoomUrl instead of the roomUrl, if you want to give the user host privileges {% endtab %} {% endtabs %}

{% hint style="info" %} If you aren't using a bundler or a library containing a bundler you can access the component code directly from our CDN using a simple Script tag in your site {% endhint %}

Attributes of the component

The web component has a variety of attributes available to customize the meeting experience for your users. It’s possible for each participant in a meeting to have different attribute combinations.

AttributeValueDescription
aecNothing (on) or "off"Turn off acoustic echo cancellation on audio
agcNothing (on) or "off"Turn off acoustic echo cancellation on audio
audio"off"Enter meeting with audio off
audioDenoiserNothing (on) or "off"Enables/Disables the noise cancelation feature
autoHideSelfViewNothing (off) or "on"Automatically hide the self view in the bottom right
autoSpotlightNothing (on) or "off"Automatically spotlight the local "host" on room join
avatarUrlImage URL - Must be HTTPS and cannot contain query paramsSet the avatar picture of the participant. The image must be a .png or .jpeg, and a square maximum of 64x64.
background"off"Render without background to let embedding app render its own
bottomToolbar"off"Hide the entire bottom tool bar. Useful if creating buttons using commands
breakoutNothing (on) or "off"Show/hide the Breakout Groups feature for the meeting host.
cameraAccessNothing (on) or "off"Disable camera access for the local participant, allowing for only audio input
cameraEffectslight-blur, blur, image-cabin, image-concrete, image-brick, image-sunrise, image-day, image-nightSet the default camera effect to be used.
chatNothing (on) or "off"Enable/disable chat
callQualityMonitoringNothing(off) or "on"Enable/disable Whereby's call quality monitoring interface
displayName100 character string - Excluding $!<>:;Set displayname of participant
externalIdUp to 36 alphanumeric characters (details)Custom identifier for the participant. Can be searched in insights endpoints
floatSelfNothing (on) or "off"Float the self view to the bottom right
groups"Group Name(s)" - EX:

"orange, banana, coconut"
Predefine up to 20 groups for the breakout groups function.
langNothing (en) or fr | it | de | nb | da | nl | pt | pl | es | hi | cs | zh-hant | jpSet the meeting UI language to match your product or service. Select from either English en, French fr, Italian it, German de, Norwegian nb, Danish da, Dutch nl, Portuguese pt, Polish pl, Spanish es, Hindi hi, Czech cs, Chinese (Complex) zh-hant or Japanese jp.
leaveButtonNothing (on) or "off"Enable/disable the leave button
localizationNothing (on) or "off"Show/hide the language picker
lockingNothing (on) or "off"Show/hide the room lock button and settings toggle
logoNothing (on) or "off"Show/hide the logo in the room header
lowDataNothing (on) or "off"Use a lower resolution by default
metadata<string><string> gets passed on to the corresponding webhooks
minimalNothing (on) or "off"Apply minimal UI for embed scenarios
moreButtonNothing (on) or "off"Show/hide the “…” button
participantCountNothing (on) or "off"Show/hide the participant counter
peopleNothing (on) or "off"Show/hide the participant list
pipButtonNothing (on) or "off"Show/hide the Picture in Picture button
precallCeremonyNothing (on) or "off"Determines if users see the pre-call device and connectivity test
precallCeremonyCanSkipNothing (off) or "on"Adds functionality for participants to skip the connectivity test
precallPermissionHelpLink<url>Specify custom help link in pre-call review step pointing users to additional support pages
roomA room URLThe full URL of the room you want to embed (required)
roomIntegrationsNothing (off) or "on"Enables YouTube and Miro integrations in the meeting
screenshareNothing (on) or "off"Enable/disable screenshare
skipMediaPermissionPromptNothing (on) or "off"Skips request permissions UI and asks for devices directly. Required for links used in Android Apps
subgridLabelsNothing (off) or "on"Show/hide name labels in the subgrid
timerNothing (on) or "off"Show/hide the meeting timer
toolbarDarkTextNothing (on) or "off"Sets button icon labels color to black.
topToolbarNothing (on) or "off"Used to toggle the entire top toolbar on/off. Top toolbar is hidden by default if using minimal
video"off"Enter meeting with video off

{% hint style="success" %} There are additional room customizations and options that can be found in the URL parameters section. These options must be added as parameters on the room source URL, and are not currently supported as attributes directly on the component. {% endhint %}

Usage examples

{% tabs %} {% tab title="Room w/ multiple customizations" %} {% code overflow="wrap" %}

<whereby-embed room="https://subdomain.whereby.com/your_room" displayName="John Smith" audio=off video=off background=off chat=off />

{% endcode %} {% endtab %}

{% tab title="Basic room embed" %}

<whereby-embed room="https://subdomain.whereby.com/your_room" />

{% endtab %}

{% tab title="Room w/ minimal UI" %} {% code overflow="wrap" %}

<whereby-embed room="https://subdomain.whereby.com/your_room" minimal />

{% endcode %} {% endtab %} {% endtabs %}

Listening to events

You can listen for events on the <whereby-embed> component. The following events are supported:

Event typeDescriptionProperties (from "detail")
readyBasic dependencies have loaded and the room is ready to be used
grant_device_permissionThe local user grants permission to camera and microphone in the pre-call screen{ granted: Boolean }
deny_device_permissionThe local user denies permission to camera and microphone in the pre-call screen{ denied: Boolean }
precall_check_completedThe local user completed the presented pre-call check steps.

Possible values for all status properties: "passed | failed".

{

status: String,

steps: {

camera: { status: String; },

speaker: { status: String; },

microphone: { status: String; },

bandwidth: { status: String; },

}

}

precall_check_skippedThe local user skipped the presented pre-call check steps-
knockThe local user knocks to get into the room
joinThe local user joins
leaveThe local user leaves{ removed: Boolean }
meeting_endA host has ended the meeting via "end meeting for all"
participantupdateA new participant join/leave{ count: Number }
participant_joinA new participant joins the room

{

participant: {

metadata: String

}

}

participant_leaveA participant leaves the room

{

participant: {

metadata: String

}

}

microphone_toggleThe local user toggles the microphone{ enabled: Boolean }
camera_toggleThe local user toggles the camera{ enabled: Boolean }
chat_toggleThe local user toggles the chat{ open: Boolean }
people_toggleThe local user toggles the people pane{ open: Boolean }
pip_toggleThe local user toggles Picture-in-Picture mode{ open: Boolean }
screenshare_toggleThe local user toggles the screenshare{ enabled: Boolean }
streaming_status_changeStreaming status changes.

Possible values: " | requested | starting | streaming | stopping | stopped"
{ status: String }
connection_status_changeUser connection status changes.

Possible values: "stable | unstable"
{ status: String }

You can use standard JavaScript to listen to the events. Here's an example:

  const elm = document.querySelector("whereby-embed");
  let output = "";

  function logEvent(event) {
    output = `got event ${JSON.stringify({ type: event.type, detail: event.detail })}\n`;
    console.log(output)
  }
  elm.addEventListener("ready", logEvent)
  elm.addEventListener("precall_check_skipped", logEvent)
  elm.addEventListener("precall_check_completed", logEvent)
  elm.addEventListener("knock", logEvent)
  elm.addEventListener("participantupdate", logEvent)
  elm.addEventListener("join", logEvent)
  elm.addEventListener("leave", logEvent)
  elm.addEventListener("participant_join", logEvent)
  elm.addEventListener("participant_leave", logEvent)
  elm.addEventListener("microphone_toggle", logEvent)
  elm.addEventListener("camera_toggle", logEvent)
  elm.addEventListener("chat_toggle", logEvent)
  elm.addEventListener("people_toggle", logEvent)
  elm.addEventListener("pip_toggle", logEvent)
  elm.addEventListener("deny_device_permission", logEvent)
  elm.addEventListener("screenshare_toggle", logEvent)
  elm.addEventListener("streaming_status_change", logEvent)
  elm.addEventListener("connection_status_change", logEvent)

Example output:

got event {"type":"ready","detail":null}
got event {"type":"deny_device_permission","detail":{"denied":false}}
got event {"type":"precall_check_completed","detail":{"status":"failed",steps: {"camera":"passed","speaker":"failed","microphone":"failed","bandwidth":"passed"}}}
got event {"type":"join","detail":null}
got event {"type":"participant_join","detail":{"metadata":"userId"}}
got event {"type":"participantupdate","detail":{"count":2}}
got event {"type":"participant_leave","detail":{"metadata":"userId"}}
got event {"type":"participantupdate","detail":{"count":1}}
got event {"type":"streaming_status_change","detail":{"status":"starting"}}
got event {"type":"connection_status_change","detail":{"status":"unstable"}}
got event {"type":"leave","detail":{"removed":false}}

Sending commands

{% hint style="warning" %} For this feature to work, you must add the origin of your application to the "Allowed domains" section in your Whereby account. If not present, the following methods will not do anything. {% endhint %}

The <whereby-embed> component exposes a set of methods your application can invoke to perform actions in the room. Currently, the following methods are available:

Method Description
endMeeting() End meeting for all on behalf of the local user, who needs to be a host in the room.
knock() Knock on a locker room, on behalf of the local user.
leaveRoom() Allows local user to leave the room.
startRecording() Start cloud recording on behalf of the local user, who needs to be a host in the room.
stopRecording() Stop cloud recording on behalf of the local user, who needs to be a host in the room.
startStreaming() Start streaming on behalf of the local user, who needs to be a host in the room.
stopStreaming() Stop streaming on behalf of the local user, who needs to be a host in the room.
startLiveTranscription() Start live transcription on behalf of the local user, who needs to be a host in the room.
stopLiveTranscription() Stop live transcription on behalf of the local user, who needs to be a host in the room.
toggleCamera([true | false]) Toggle the local user's camera on or off. Without any arguments, it toggles depending on current state.
toggleMicrophone([true | false]) Toggle the local user's microphone on or off. Without any arguments, it toggles depending on current state.
toggleScreenshare([true | false]) Toggle the local user's screenshare on or off. Without any arguments, it toggles depending on current state.
toggleChat([true | false]) Toggle the local user's chat open or closed. Without any arguments, it toggles depending on current state.

Here is a small example showing uses of these methods:

const room = document.querySelector("whereby-embed");
room.startRecording(); // Start cloud recording
room.stopRecording(); // Stop cloud recording
room.startStreaming(); // Start streaming
room.stopStreaming(); // Stop streaming
room.startLiveTranscription(); // Start live transcription
room.stopLiveTranscription(); // Stop live transcription
room.toggleCamera(); // Camera will be turned on if off, and off if on
room.toggleMicrophone(); // Microphone will be turned on if off, and off if on
room.toggleScreenshare(); // Screenshare will be turned on if off, and off if on
room.toggleChat(); // Chat will be opened if on, and closed if off
room.toggleCamera(true); // Turn camera on
room.toggleMicrophone(true); // Turn microphone on
room.toggleScreenshare(true); // Turn screenshare on
room.toggleCamera(false); // Turn camera off
room.toggleMicrophone(false); // Turn microphone off
room.toggleScreenshare(false); // Turn screenshare off