Skip to main content
Version: 5.x.x

HLS Events - Flutter

VideoSDK provides the hlsStateChanged event, which informs you about the current state of HLS for the room.

Events.hlsStateChanged​

  • This event is triggered when the HLS status of the room changes.
  • It can be subscribed to using the Room Object.
  • The handler receives the state as a String and an HLSUrl?. When the state is HLS_PLAYABLE, hlsUrl carries playbackHlsUrl and livestreamUrl.
  • The latest URLs are also on room.hlsUrl.

Example​

Here is an example demonstrating the usage of the event mentioned on this page.

import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:videosdk/videosdk.dart';

class RoomScreen extends StatefulWidget {
//Existing configuration
}

class _RoomScreenState extends State<RoomScreen> {
late Room room;

@override
void initState() {
super.initState();
//Existing configuration

setupRoomEventListener();
}

@override
Widget build(BuildContext context) {
return YourRoomWidget();
}

void setupRoomEventListener() {
room.on(Events.hlsStateChanged, (String state, HLSUrl? hlsUrl) {
//State can be :: HLS_STARTING
//State can be :: HLS_STARTED
//State can be :: HLS_PLAYABLE
//State can be :: HLS_STOPPING
//State can be :: HLS_STOPPED
log("Room HLS state : $state");
if (state == "HLS_PLAYABLE") {
log("PLAYBACKHLS URL -- ${hlsUrl?.playbackHlsUrl}");
}
});
}
}

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