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

Create a live event

Copy link

The first step is to configure the live event by providing a LiveEventCreateParams object. You can provide some basic information related to the event such as the type of the live event, title, and the cover image that shows up on the thumbnail. If not specified, the live event ID shows up as the title and the thumbnail shows up as black.

When creating a live event, you need to provide the type to specify the type of a live event. The supported features of an event will vary depending on the live event type. The type of the event can't be changed once the event is created. For instance, if you wish to transition from an audio-only event to an event with both audio and video, a brand new live event must be created.

Once you have configured the LiveEventCreateParams object, you can create a liveEvent instance. Pass the LiveEventCreateParams object by calling the createLiveEvent() method. If the creation was successful, a liveEvent instance is returned, the status of the live event changes to created, and a new open channel becomes available. Host can enter the live event to chat and test their media stream before letting participants in the event.

To start a live event, you need at least one host for each live event. For users to enter the live event as a host, provide the IDs of host candidates in the userIdsForHost property of LiveEventCreateParams. Up to ten users can be set as host candidates and six of them can act as co-hosts for the live event simultaneously while other four can join the event as participants. When there is an empty seat for the role during the live event, anyone among the four, specified in userIdsForHost, can become a host by re-entering the live event as a host.

In case the open channel isn’t available, call fetchOpenChannel() to fetch the open channel.

/*
export enum LiveEventType {
  LIVE_EVENT_FOR_VIDEO = 'live_event_for_video',
  LIVE_EVENT_FOR_AUDIO_ONLY = 'live_event_for_audio_only',
}

export interface LiveEventCreateParams {
    userIdsForHost?: string[];
    type: LiveEventType;
    title?: string;
    coverUrl?: string;
    coverFile?: File;
    customType?: string;
}
*/

let liveEvent = null;

const params = {
    userIdsForHost: [CURRENT_USER_ID],
    type: LiveEventType.LIVE_EVENT_FOR_VIDEO,
    title: 'New Event',
    coverUrl: IMAGE_URL // or coverFile: IMAGE_FILE
}

try {
    liveEvent = await SendbirdLive.createLiveEvent(params);
} catch (e) {
    // Handle error.
}