Skip to main content
Version: Next

Stop HLS - Flutter

This could refer to stopping the transmission of an ongoing HLS stream, which would mean the stream is no longer available to viewers.

Stopping HLS

stopHls() can be used to stop a interactive livestream of the meeting which can be accessed from the Room object.

Example

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

class MeetingScreen extends StatefulWidget {
...
}

class _MeetingScreenState extends State<MeetingScreen> {
late Room _room;

@override
void initState() {
...
}

@override
Widget build(BuildContext context) {
return Column(
children:[
ElevatedButton(
onPressed:(){
_room.stopHls();
},
child: const Text("Stop HLS"),
),
]
);
}
}

Event associated with HLS

  • hlsStateChanged - Whenever meeting HLS state changes, then hlsStateChanged event will trigger.

  • You will get HLS_STOPPING and HLS_STOPPED status on calling stopHls().

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

class MeetingScreen extends StatefulWidget {
...
}

class _MeetingScreenState extends State<MeetingScreen> {
late Room room;

@override
void initState() {
...

setupRoomEventListener();
}

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

void setupRoomEventListener() {
room.on(Events.hlsStateChanged, (Map<String, dynamic> data) {
//Status can be :: HLS_STARTING
//Status can be :: HLS_STARTED
//Status can be :: HLS_PLAYABLE
//Status can be :: HLS_STOPPING
//Status can be :: HLS_STOPPED
log("Meeting HLS status : ${data['status']}");
if (data['status'] == "HLS_STOPPING")
log("HLS Stopping");
if (data['status'] == "HLS_STOPPED")
log("HLS Stopped");
});
}
}

Custom Template

With VideoSDK, you can also use your own custom designed layout template to livestream the meetings. In order to use the custom template, you need to create a template for which you can follow this guide. Once you have setup the template, you can use the REST API to start the livestream with the templateURL parameter.

API Reference

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

Got a Question? Ask us on discord