githubEdit

Using commands

Now that you've mastered attributes, let's move onto using custom commands!

The <whereby-embed> web component exposes a set of methods your application can invoke to perform actions in the room. This is ideal for implementing custom controls for your Whereby component-based video call functionality. In this article, we'll show you how to recreate the bottom toolbar, which we hid at the end of the Configuring with attributes guide.

Prerequisites

This guide assumes that you’ve already created a Whereby Embedded account and a meeting room, and have joined it by adding the <whereby-embed> component to a web app.

Getting started

  1. Open your example web app in your browser and your code editor.

  2. If you're using your own example, make sure you've got the bottomToolbar="off" attribute set on your <whereby-embed> attribute.

  3. From your account dashboard, go to "Configure" > "API". Under the Allowed domains panel, add the domain where your web app is running. In general, this must be https, but http://localhost domains are allowed for testing purposes. Your app domain must be present here; otherwise, the Whereby commands will not work.

  4. Press the Save button that appears under the text field.

Adding control buttons

In this article, we are going to re-implement our own custom versions of the Camera, Microphone, Chat, People, and Leave controls. The first thing we need to achieve this is an HTML button bar.

Add the following HTML snippet to your document, above the <whereby-embed> element:

<section id="button-bar">
  <button id="camera">Mute video</button>
  <button id="mic">Mute audio</button>
  <button id="chat">Show chat</button>
  <button id="people">Show people</button>
  <button id="leave">Leave meeting</button>
</section>

Styling the button bar

Let's give our buttons some style.

  1. Add the following CSS to your stylesheet to make sure the <body> element spans the full height of the screen, but the <whereby-embed> element leaves a gap at the bottom to make space for the button bar. If you are starting from our finished web component quickstart web app with attributes example, you'll also want to remove the current CSS rule that targets body and whereby-embed.

  2. Next, add the following rule to place the button bar in the gap at the bottom of the screen, center the buttons, and get things looking neat:

Adding button functionality

Now we'll get our buttons working.

  1. Add the following line to the bottom of your HTML <head>:

  2. Create an index.js file in your app directory and add the following statements to grab references to your control buttons and the <whereby-embed> element:

  3. Add the following event handler functions to perform the expected actions when you press those buttons:

circle-info

See also

Last updated

Was this helpful?