BASS.NET API for the Un4seen BASS Audio LibraryBassWmaBASS_WMA_StreamCreateFileAuth Method (String, Int64, Int64, BASSFlag, String, String)BASS.NET API for the Un4seen BASS Audio Library
Creates a sample stream from a WMA file.

This overload implements Unicode filenames, username and password. The BASS_UNICODE flag will be added automatically.

Namespace: Un4seen.Bass.AddOn.Wma
Assembly: Bass.Net (in Bass.Net.dll) Version:

public static int BASS_WMA_StreamCreateFileAuth(
	string file,
	long offset,
	long length,
	BASSFlag flags,
	string user,
	string pass


Type: SystemString
Filename or URL for which a stream should be created.
Type: SystemInt64
File offset to begin streaming from (Unused, set to 0).
Type: SystemInt64
Data length... 0 = use all data up to the end of the file.
Type: Un4seen.BassBASSFlag
Any combination of these flags: see BASSFlag.
Type: SystemString
Username to use in connecting to the server... if either this or pass is , then no username/password is sent to the server.
Type: SystemString
Password to use in connecting to the server

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.

This function is identical to BASS_WMA_StreamCreateFile(String, Int64, Int64, BASSFlag), but with the additional authentication options.

Use BASS_ChannelGetInfo(Int32, BASS_CHANNELINFO) to retrieve information on the format (sample rate, resolution, channels) of the stream. The bitrate (amongst other things) can be retrieved through BASS_ChannelGetTags(Int32, BASSTag) (BASS_TAG_WMA). When retrieving tags, a pointer to a series of null-terminated UTF-8 strings is returned, the final string ending with a double null.

A description of the codec used by the file is also available from BASS_ChannelGetTags(Int32, BASSTag) (BASS_TAG_WMA_CODEC). 2 null-terminated UTF-8 strings are returned, with the 1st string being the name of the codec, and the 2nd containing additional information like what VBR setting was used.

The playback length of the stream can be retrieved using BASS_ChannelGetLength(Int32, BASSMode). Until the whole file has been streamed, whatever length the file's header says is returned, which may or may not be exact.

Although the Windows Media modules uses it's own internet streaming code (not BASS's), the BASS_CONFIG_NET_TIMEOUT (see BASS_SetConfig(BASSConfig, Int32)) config option does have effect when opening WMA streams. None of the other NET config options apply.

With local files, BASS_StreamGetFilePosition(Int32, BASSStreamFilePosition) works the same as with the BASS built-in stream formats. But when internet streaming, the Windows Media modules uses it's own streaming routines. The download progress of an internet streamed file can be retrieved with BASS_StreamGetFilePosition(Int32, BASSStreamFilePosition) (BASS_FILEPOS_DOWNLOAD). The file size (BASS_FILEPOS_END) can also be retrieved, but getting the size of internet streamed files requires Windows Media 9 to be installed. The decode position (BASS_FILEPOS_CURRENT) is not available. When streaming a file from the internet, it is not possible to seek with BASS_ChannelSetPosition(Int32, Int64, BASSMode) until the whole file has been downloaded. A sync (BASS_ChannelSetSync(Int32, BASSSync, Int64, SYNCPROC, IntPtr) with BASS_SYNC_DOWNLOAD) can be set to be notified when the file has been downloaded.

When streaming a file from the internet, it's not possible to seek with BASS_ChannelSetPosition(Int32, Int64, BASSMode) until the whole file has been downloaded. A sync (BASS_SYNC_DOWNLOAD) can be set to be notified when the file has been downloaded.

With Windows Media versions prior to 9 (and when streaming from the internet), WMA decoding is performed in a separate thread, so the CPU used to decode a file/stream during playback will not be included in the BASS_GetCPU return value.

When using the BASS_STREAM_DECODE flag, it's not possible to play the stream. Because the decoded sample data is not outputted, "decoding channels" can still be used when there is no output device (using the "no sound" device with BASS_Init(Int32, Int32, BASSInit, IntPtr, IntPtr)).

The sample rate of local files can be altered with BASS_ChannelSetAttribute(Int32, BASSAttribute, Single). But the playback rate of internet streams should not be changed, because they are decoded at a fixed rate - the rate required to sustain playback at normal speed. So increasing the rate will result in playback stalling.

Using VBR, lossless and multi-channel WMA files/streams requires Windows Media 9 to be installed.

ERROR CODEDescription
BASS_ERROR_WMAThe Windows Media modules (v9 or above) are not installed.
BASS_ERROR_INITBASS_Init(Int32, Int32, BASSInit, IntPtr, IntPtr) has not been successfully called.
BASS_ERROR_NOTAVAILOnly decoding channels (BASS_STREAM_DECODE) are allowed when using the "no sound" device. The BASS_STREAM_AUTOFREE flag is also unavailable to decoding channels.
BASS_ERROR_ILLPARAMOne or more of the parameters are invalid.
BASS_ERROR_FILEOPENThe file could not be opened.
BASS_ERROR_FILEFORMThe file's format is not recognised/supported.
BASS_ERROR_CODECThere is no appropriate codec installed to decode the file. Try installing the latest Windows Media codecs.
BASS_ERROR_FORMATThe sample format is not supported by the device/drivers. If the stream is more than stereo or the BASS_SAMPLE_FLOAT flag is used, it could be that they are not supported.
BASS_ERROR_SPEAKERThe specified SPEAKER flags are invalid. The device/drivers do not support them, they are attempting to assign a stereo stream to a mono speaker or 3D functionality is enabled.
BASS_ERROR_MEMThere is insufficient memory.
BASS_ERROR_NO3DCould not initialize 3D support.
BASS_ERROR_WMA_LICENSEThe WMA file can not be played because it is protected.
BASS_ERROR_UNKNOWNSome other mystery problem!

See Also