Stop HLS - Javascript
Stopping HLS refers to the process of halting the ongoing HLS stream transmission, indicating that the stream is no longer accessible to viewers.
This page uses the following asynchronous methods. Refer to their API reference for the errors each Promise may reject with, and handle these rejections appropriately based on your use case.
Stopping HLS
The stopHls() method, accessible from the meeting object, is used to stop the interactive livestream of a meeting.
Example
let meeting;
// Initialize Meeting
meeting = VideoSDK.initMeeting({
// ...
});
const stopHlsBtn = document.getElementById("stopHlsBtn");
stopHlsBtn.addEventListener("click", async () => {
// Stop HLS
try {
await meeting?.stopHls();
} catch (err) {
console.error("stopHls failed:", err);
}
});
Event associated with HLS
-
hls-state-changed - The
hls-state-changedevent is triggered whenever the state of meeting HLS changes. -
You will get
HLS_STOPPINGandHLS_STOPPEDstatus on callingstopHls().
downstreamUrl is now depecated. Use playbackHlsUrl or livestreamUrl in place of downstreamUrl
let meeting;
// Initialize Meeting
meeting = VideoSDK.initMeeting({
// ...
});
const Constants = VideoSDK.Constants;
meeting.on("hls-state-changed", (data) => {
const { status } = data;
if (status === Constants.hlsEvents.HLS_STARTING) {
console.log("Meeting Hls is starting");
} else if (status === Constants.hlsEvents.HLS_STARTED) {
// on hlsStateChanged started you will receive playbackHlsUrl and livestreamUrl
const { playbackHlsUrl } = data;
console.log("Meeting Hls is started");
} else if (status === Constants.hlsEvents.HLS_STOPPING) {
console.log("Meeting Hls is stopping");
} else if (status === Constants.hlsEvents.HLS_STOPPED) {
console.log("Meeting Hls is stopped");
} else {
//
}
});
API Reference
The API references for all the methods utilized in this guide are provided below.
Got a Question? Ask us on discord

