HlsPlay Function

Action

Starts downloading stream segments and simulates playback of the HLS stream associated with the stream handle. A web function to request a playlist (.m3u8) resource must be called prior to HlsPlay to associate the stream handle with the stream. The function blocks until either the stream playback completed or the playback was interrupted due to a buffer underrun.

The HlsPlay function leads to shorter scripts as it prevents that every single media segment is listed in the script. It also ensures that the resulting TrueLog remains clear, because all media segments are listed under the respective node in the tree. Furthermore, it enables recording dynamically generated live playlists in the first place, as this would not be possible with conventional recording.

Include file

hls.bdh

Syntax

HlsPlay( in hStream     : number,
         in sIdentifier : string optional,
         in fStartTime  : double optional,
         in fDuration   : double optional,
         in sTimer      : string optional): boolean;
Parameter Description
hStream Handle to HLS stream that was created by HlsInit function.
sIdentifier Specifies the value of the EXT-X-MEDIA tag's NAME or BANDWIDTH attribute or its 1-based index within the master playlist. By default, the first stream in the master playlist is chosen. (optional). For example: If the first stream in your master playlist had the attributes BANDWIDTH=246440, NAME="smallResolution", you could choose it by specifying the identifiers smallResolution (for the name), 246440 (for the bandwidth), 1 (the index of the first element), or by leaving it empty (default).
fStartTime Specifies the start time in seconds (optional). The default value is 0.0. Requires a float, so make sure to include a comma with your value.
fDuration Specifies the duration in seconds (optional). Specify FULL_STREAM (default) for a complete playback. Requires a float, so make sure to include a comma with your value.
sTimer Optional timer name to associate measures with the stream. If a timer name is provided, Silk Performer reports stream statistics.

Return value

  • true if the play attempt is completed successfully
  • false otherwise

Example

dcltrans
    transaction TNoParams
  var
    hStream : number;
  begin
    hStream := HlsInit();
    WebUrl("http://lnz-streaming/basic/basicshort.m3u8");
    HlsPlay(hStream, "Identifier", 0.0, 60.0, "MyLiveStream");
  end TNoParams;