Skip to main content

Broadcasting

The Stream Video SDK has support for HLS broadcasting.

Start and Stop HLS broadcasting

call.startHLS()
call.stopHLS()

After few seconds of setup, broadcasting will start and the state of the call will be updated: the call.state.broadcasting boolean flag will become true.

Listening to Broadcasting Events

You can listen to broadcasting-related events and change to UI accordingly.

val sub = subscribeFor(
CallHLSBroadcastingStartedEvent::class.java,
CallHLSBroadcastingStoppedEvent::class.java,
CallHLSBroadcastingFailedEvent::class.java,
) {
Log.e(TAG, "Event type: ${it.getEventType()}")
}

// stop listening
sub.dispose()

See more about subscribing to events on the events page.

Retrieving the Broadcast URL

The URL for the broadcast can be retrieved from the CallHLSBroadcastingStartedEvent event. It can be used by others to watch the broadcast.

call.subscribe { event ->
when (event) {
is CallHLSBroadcastingStartedEvent -> {
Log.d(TAG, event.hlsPlaylistUrl)
}
}
}

Displaying HLS

On Android you can play a HLS broadcast by using ExoPlayer.

implementation "androidx.media3:media3-exoplayer:1.0.2"
implementation "androidx.media3:media3-ui:1.0.2"
implementation "androidx.media3:media3-exoplayer-hls:1.0.2"

This article explains how to use ExoPlayer with Compose.

RTMP-In

You can also use RTMP streams as input for a call.

val url = call.state.ingress.value?.rtmp?.address
val streamingKey = call.state.ingress.value?.rtmp?.streamKey

You can read more about RTMP-In in our livestreaming tutorial.

We plan to add support for other livestreaming protocols in the future. If something is missing be sure to let us know.

Did you find this page helpful?