Skip to main content
Version: 2.0.x

Interactive Livestream (HLS) - iOS

Interactive live streaming (HLS) refers to a type of live streaming where viewers can actively engage with the content being streamed and with other viewers in real-time.

In an interactive live stream (HLS), viewers can take part in a variety of activities like live polling, Q&A sessions, and even sending virtual gifts to the content creator or each other.

VideoSDK-HLS

VideoSDK also allows you to configure the interactive livestream layouts in numerous ways like by simply setting different prebuilt layouts in the configuration or by providing your own custom template to do the livestream according to your layout choice.

This guide will provide an overview of how to implement start and stop Interactive live streaming (HLS).

important

To initiate automatic Interactive live streaming (HLS) at the beginning of a session, simply provide the autoStartConfig feature hls during room creation. For more information on configuring the autoStartConfig, please refer to the provided documentation here.

startHLS()

startHLS() can be used to start a interactive livestream of the meeting which can be accessed from the useMeeting hook. This method accepts one parameter:

  • config (optional): This parameter will define how the interactive livestream layout should look like.

  • transcription(optional): This parameter will be used to enable post transcription for the recording with the given config.

let config: HLSConfig = HLSConfig(

// Layout Configuration
layout: HLSLayout(
type: .GRID, // .SPOTLIGHT | .SIDEBAR, Default : .GRID
priority: .SPEAKER, // .PIN, Default : .SPEAKER
gridSize: 4 // MAX : 25
),

// Theme of livestream
theme: .DARK, // .LIGHT | .DEFAULT

// `mode` is used to either interactive livestream video & audio both or only audio.
mode: .video_and_audio, // .audio, Default : .video_and_audio

// Quality of livestream and is only applicable to `video-and-audio` type mode.
quality: .high, // .low | .med, Default : .med

// This mode refers to orientation of recording.
// landscape : Livestream the meeting in horizontally
// portrait : Livestream the meeting in vertically (Best for mobile view)
orientation: .portrait // .portrait, Default : .landscape
)

let transcription: PostTranscriptionConfig = PostTranscriptionConfig(
enabled: true,
summary: SummaryConfig(
enabled: true,
prompt: "Write summary in sections like Title, Agenda, Speakers, Action Items, Outlines, Notes and Summary"
)
)

startHLS(config: config, transcription: transcription)

stopHLS()

  • stopHLS() is used to stop interactive livestream of the meeting which can be accessed from the meeting object.

Example

stopHLS();

Event associated with HLS

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

  • You can get the downstreamUrl of the HLS to play it on the Viewer side when the state changes to HLSState.HLS_STARTED

func onHlsStateChanged(state: HLSState, hlsUrl: HLSUrl?) {
switch(state) {
case .HLS_STARTING:
print("HLS Starting")

case .HLS_STARTED:
self.hlsStreamStarted = true
print("HLS Started")

case .HLS_PLAYABLE:
print("HLS Playable")

case .HLS_STOPPING:
print("HLS Stopping")

case .HLS_STOPPED:
self.hlsStreamStarted = false
print("HLS Stopped")
}
}

API Reference

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

Got a Question? Ask us on discord