Assembly: Bass.Net (in Bass.Net.dll) Version: 22.214.171.124
public static int BASS_HLS_StreamCreateURL( string url, int offset, BASSFlag flags, DOWNLOADPROC proc, IntPtr user )
Public Shared Function BASS_HLS_StreamCreateURL ( url As String, offset As Integer, flags As BASSFlag, proc As DOWNLOADPROC, user As IntPtr ) As Integer
- Type: SystemString
URL of the file to stream. Should begin with "http://" or "ftp://".
- Type: SystemInt32
File position to start streaming from. This is ignored by some servers, specifically when the file length is unknown.
- Type: Un4seen.BassBASSFlag
Any combination of these flags: see BASSFlag.
- Type: Un4seen.BassDOWNLOADPROC
Callback function to receive the file as it is downloaded... = no callback.
- Type: SystemIntPtr
User instance data to pass to the callback function.
Return ValueType: Int32
If successful, the new stream's handle is returned, else 0 is returned. Use BASS_ErrorGetCode to get the error code.
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.