100ms Logo

100ms

Docs

Search docs
/

HLS Streaming

HLS Streaming allows for scaling to millions of viewers in near real time. You can give a link of your web-app which will be converted to a HLS feed by our server and can be played across devices for consumption.

Behind the scenes, this will be achieved by having a bot join your room and stream what it sees and hears. Once the feed is ready, the server will give a URL which can be played using any HLS Player.

Note that the media server serving the content in this case is owned by 100ms. If you're looking for a way to stream on YouTube, Twitch etc., please have a look at our RTMP streaming docs here.

Starting HLS

To start HLS you can call hmsSDK.startHlsStreaming method. The 100ms bot will open default meeting URL to join your room, so it must allow access without any user level interaction. In the future it'll be possible to start HLS for multiple such URLs for the same room.

For this purpose the API supports taking in an array, although currently only the first element of the array will be used. To distinguish between multiple URLs an additional field metadata can be optionally passed. The meetingUrl and metadata are clubbed together to form what we'll call a variant.

You can call hmsSDK.startHlsStreaming with a optional parameter HMSHLSConfig having an array of such variants.

hmsSDK.startHlsStreaming(hmsActionResultListener: hmsActionResultListener);
class HMSHLSConfig { List<HMSHLSMeetingURLVariant>? meetingURLVariant; HMSHLSRecordingConfig? hmsHLSRecordingConfig; }

Want to see how this works in a live project? Take a look at our advanced sample app.

Current Room Status

The current status for the room is always reflected in the HMSRoom object.

Here are the relevant properties inside the HMSRoom object which you can read to get the current hls streaming status of the room namely: hlsStreamingState.

The object contains a boolean running which lets you know if it's active on the room right now as well as list of active variants.

  1. hlsStreamingState an instance of HMSHLSStreamingState, which looks like:
class HMSHLSStreamingState( bool running; List<HMSHLSVariant?> variants; )

This represents a livestream to one or more HLS URLs in the container of HMSHLSVariant. Which looks like:

class HMSHLSVariant( String? hlsStreamUrl; String? meetingUrl; String? metadata; DateTime? startedAt; )

The room status should be checked in following two places -

  1. In the onJoin(room: HMSRoom) callback of HMSUpdateListener The properties mentioned above will be on the HMSRoom object.
  2. In the onRoomUpdate(type: HMSRoomUpdate, hmsRoom: HMSRoom) callback of HMSUpdateListener. The HMSRoomUpdate type will be HMSRoomUpdate.HLS_STREAMING_STATE_UPDATED.

Tips

  • If you're using the dashboard web-app from 100ms, please make sure to use a role which doesn't have publish permissions for beam tile to not show up.
  • If using your own web-app, do put in place retries for API calls like tokens etc. just in case any call fails. As human users we're used to reloading the page in these scenarios which is difficult to achieve in the automated case.
  • Make sure to not disable the logs for the passed in meeting URL. This will allow for us to have more visibility into the room, refreshing the page if join doesn't happen within a time interval.