githubEdit

Using Whereby events

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

The <whereby-embed> web component fires custom events that allow your application to respond to real-time changes in the meeting room. This enables you to create dynamic user interfaces, provide helpful feedback, and implement custom behaviors based on what's happening during the video call.

In this article, we'll show you how to enhance your custom controls with event-driven features, like participant counters and connection status indicators.

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

Event listeners allow your application to react to changes in the meeting room without constantly checking the room's state. This is essential for creating responsive user interfaces that provide real-time feedback to users. For example, you can update participant counts as people join and leave, show connection quality indicators, or display helpful messages when users encounter issues.

Open your existing web app with custom controls in your browser and code editor. We'll be building on the button bar you created in the commands tutorial to add dynamic status indicators and user feedback.

Adding a Status Bar

First, let's add a status bar above your existing button bar to display real-time information about the meeting.

Add the following HTML snippet to your document, above the existing #button-bar:

<section id="status-bar">
  <div id="participant-count">Participants: 0</div>
  <div id="connection-status">Connection: Good</div>
  <div id="notification"></div>
</section>

Styling the Status Bar

Let's style the new status bar and adjust the existing layout to accommodate it.

First, update your existing CSS rules to make room for both bars:

Now, add styling for the status bar:

Implementing Participant Counter

Now let's add JavaScript to track participants in real-time. Add the following code to your existing index.js file:

Adding Connection Status Monitoring

Connection quality is crucial for video calls. Let's add a connection status indicator that updates in real-time:

Creating a Notification System

Add a helper function to display temporary notifications to users:

Room Lifecycle Management

Finally, let's add some room lifecycle events to provide a complete user experience:

Your enhanced video call interface now provides real-time feedback to users about participant changes, connection quality, device issues, and room status. The event-driven approach ensures your UI stays synchronized with the actual state of the meeting without requiring manual polling or state management.

See Also

Last updated

Was this helpful?