Stop HLS - React
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 useMeeting hook, is used to stop the interactive livestream of a meeting.
Example
import { useMeeting } from "@videosdk.live/react-sdk";
const MeetingView = () => {
const { stopHls } = useMeeting();
const handleStopHls = async () => {
// Stop Hls
try {
await stopHls();
} catch (err) {
console.error("stopHls failed:", err);
}
};
return (
<>
<button onClick={handleStopHls}>Stop Hls</button>
</>
);
};
Event associated with HLS
-
onHlsStateChanged - The
onHlsStateChanged()event 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
import { Constants, useMeeting } from "@videosdk.live/react-sdk";
function onHlsStateChanged(data) {
const { status } = data;
if (status === Constants.hlsEvents.HLS_STARTING) {
console.log("Meeting Hls is starting");
} else if (status === Constants.hlsEvents.HLS_STARTED) {
console.log("Meeting Hls is started");
} else if (status === Constants.hlsEvents.HLS_PLAYABLE) {
// on hlsStateChanged started you will receive playbackHlsUrl and livestreamUrl
const { playbackHlsUrl } = data;
console.log("Meeting Hls is Playable");
} 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 {
//
}
}
const {
meetingId
...
} = useMeeting({
onHlsStateChanged,
...
});
API Reference
The API references for all the methods utilized in this guide are provided below.
Got a Question? Ask us on discord

