Live SDKs JavaScript v1
Live SDKs JavaScript
Live SDKs
JavaScript
Version 1

Enter a live event

Copy link

A user can enter any live events that are in ready or ongoing states by calling the liveEvent.enter() method. When a user enters a live event, the user is counted as a participant.

When a user enters a live event that is ready, they can chat but can't watch the event yet because the host's media stream isn't available to them. When a user enters an ongoing live event, they can chat and watch the event when the host starts streaming.

In a live event that supports video streaming, a HTMLVideoElement must be provided for users to watch the live event when they enter the event. To watch the media content streamed from the host, set the video view by calling liveEvent.setMediaViewForLiveEvent(videoView, hostId).

// Provide a video view to show the live event.

try {
    await liveEvent.enter();
} catch (e) {
    // Handle error.
}

For a participant to receive the video view of the host who starts the live event, set the video view using liveEvent.host.hostId. When a different user becomes a host during the live event, subscribe to the onHostEntered event and set the video using liveEvent.host.hostId to view the new host's video.

For the best experience, here are some components included in the SDK that you can use in creating the participant view.