BASS.NET API for the Un4seen BASS Audio LibraryBassHlsBASS_HLS_StreamCreateURL Method BASS.NET API for the Un4seen BASS Audio Library
Creates a sample stream from an HLS playlist on the internet, optionally receiving the downloaded data in a callback.

Namespace: Un4seen.Bass.AddOn.Hls
Assembly: Bass.Net (in Bass.Net.dll) Version: 2.4.12.0
Syntax

public static int BASS_HLS_StreamCreateURL(
	string url,
	int offset,
	BASSFlag flags,
	DOWNLOADPROC proc,
	IntPtr user
)

Parameters

url
Type: SystemString
URL of the file to stream. Should begin with "http://" or "ftp://".
offset
Type: SystemInt32
File position to start streaming from. This is ignored by some servers, specifically when the file length is unknown.
flags
Type: Un4seen.BassBASSFlag
Any combination of these flags: see BASSFlag.
proc
Type: Un4seen.BassDOWNLOADPROC
Callback function to receive the file as it is downloaded... = no callback.
user
Type: SystemIntPtr
User instance data to pass to the callback function.

Return Value

Type: Int32
If successful, the new stream's handle is returned, else 0 is returned. Use BASS_ErrorGetCode to get the error code.
Remarks

Works in the same way BASS_StreamCreateURL(String, Int32, BASSFlag, DOWNLOADPROC, IntPtr) does - so for details look there.

HLS streams consist of a media playlist and segments. The media segments usually contain AAC audio data, but MP3 or AC3 are also possible. AAC support is available as standard with BASS via OS codecs on some platforms, but the BASS_AAC add-on can otherwise be used to provide that support; BASSHLS can make use of any add-on that has been loaded via BASS_PluginLoad(String). The data will usually be in an MPEG-TS container, but it can also be plain audio data, possibly with ID3v2 tags.

As well as possibly ID3v2 tags, the current segment's EXTINF tag in the media playlist is available from BASS_ChannelGetTags with the BASS_TAG_HLS_EXTINF tag type. If present, the ID3v2 tags can/will change with each segment. A sync can be set to be informed of when a new segment starts downloading, which could be used to refresh the tags. The current segment's sequence number is available from BASS_StreamGetFilePosition(Int32, BASSStreamFilePosition) with BASS_FILEPOS_HLS_SEGMENT.

A DOWNLOADPROC callback function can be used to receive the downloaded data from all of the segments. When the data is in an MPEG-TS container, the audio data will be extracted from the container before being passed to the callback function.

Master playlists are supported, but BASSHLS will simply play the first entry from them. If you would like to play a different entry (eg. perhaps for a different bitrate), you could download the master playlist separately and then extract the wanted entry's URL from it and pass that to BASSHLS.

The BASS_STREAM_BLOCK flag is applied automatically to HLS streams, which means only a small amount of the downloaded data will be kept in memory. Be careful not to stop/pause the stream for too long, otherwise the connection may timeout due to there being no activity.

See Also

Reference