Skip to main content
Version: 0.x.x

Join Live Stream - JavaScript

Once, the live stream is configured, the next step is to join it. With our JS SDK, you can call the join() method. If you have not initialized the live stream yet, you can follow the guide here.

join()

  • To join the live stream you can call the join() method wmethod on the created liveStream object.
  • This method can be invoked after the ive stream is initialized using the initMeeting method.

Events associated with the join() method

Following events are received when a participant successfully joins the livestream.

let liveStream;

// Initialize Meeting
liveStream = VideoSDK.initMeeting({
// ...
});

const joinBtn = document.getElementById("joinBtn");

joinBtn.addEventListener("click", () => {
// Joining Meeting
liveStream?.join();
});

liveStream.on("meeting-joined", () => {
console.log("liveStream Joined Successfully");
});

liveStream.on("participant-joined", (participant) => {
console.log("New Participant Joined: ", participant.id);
});

leave()

  • To leave the live stream you can call the leave() method on the created liveStream object.
note

This method can be called only after the live stream is joined successfully.

Events associated with the leave() method

Following callbacks are received when a participant leaves the live stream.

let liveStream;

// Initialize Meeting
liveStream = VideoSDK.initMeeting({
// ...
});

const leaveBtn = document.getElementById("leaveBtn");

leaveBtn.addEventListener("click", () => {
liveStream?.leave();
});

liveStream.on("meeting-left", () => {
console.log("liveStream left Successfully");
});

liveStream.on("participant-left", (participant) => {
console.log("Participant left: ", participant.id);
});

API Reference

The API references for all the methods and events utilized in this guide are provided below.

Got a Question? Ask us on discord