BASS.NET API for the Un4seen BASS Audio LibraryBassWmaBASS_WMA_EncodeSetTag Method (Int32, String, String, BASSWMATag)BASS.NET API for the Un4seen BASS Audio Library
Sets a tag in a WMA encoding.

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

public static bool BASS_WMA_EncodeSetTag(
	int handle,
	string tag,
	string value,
	BASSWMATag type


Type: SystemInt32
The encoder handle.
Type: SystemString
The tag to set.

The standard WMA header tags are as follows:

TitleContent title.
AuthorName of the content author (Artist).
DescriptionDescription of the content.
RatingContent rating.
CopyrightContent copyright message.
WM/AlbumTitleAlbum title.
WM/PromotionURLURL to an HTML page containing related information.
WM/AlbumCoverURLURL to an HTML page containing an image of the album cover.
WM/GenreGenre of the music.
WM/YearYear of publication of the music.
Type: SystemString
The tag's text/data.
Type: Un4seen.Bass.AddOn.WmaBASSWMATag
The format of the tag and value strings. One of the following (see BASSWMATag):
BASS_WMA_TAG_ANSIANSI strings (actually not used and automatically converted to BASS_WMA_TAG_UNICODE).
BASS_WMA_TAG_UNICODEUnicode (UTF-16) strings (recommended for .Net).
You don't actually need to set any flags here, since we automatically add the BASS_WMA_TAG_UNICODE flag, unless you explititly set the BASS_WMA_TAG_UTF8 flag.

Return Value

Type: Boolean
If succesful, is returned, else is returned. Use BASS_ErrorGetCode to get the error code.

Where the tags are located in the encoded stream depends on when this function is used. Calling this function before beginning encoding data puts the tags in the stream's header. Calling this function after encoding has begun puts the tags in the actual stream data, at the current encoding position.

Header tags must be set before encoding any data - no more header tags can be set once BASS_WMA_EncodeWrite(Int32, IntPtr, Int32) has been called.

To set tags mid-stream (after encoding has begun), the BASS_WMA_ENCODE_SCRIPT flag needs to have been specified in the encoder's creation. A mid-stream tag typically used is "Caption", which get's displayed in Windows Media Player 9 and above (if the user has enabled captions).

When using a network encoder, it should be noted that while all header tags are sent to newly connecting clients, prior mid-stream tags are not. So if, for example, you're using the "Caption" tag to indicate the current song title, it should be sent at fairly regular intervals (not only at the start of the song).

On the playback side, mid-stream tags can be processed using BASS_ChannelSetSync(Int32, BASSSync, Int64, SYNCPROC, IntPtr) (with BASS_SYNC_META).

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not valid.
BASS_ERROR_NOTAVAILThe encoder does not have mid-stream tags enabled, so tags can not be set once encoding has begun.
BASS_ERROR_ILLPARAMtag and/or value is invalid.
BASS_ERROR_UNKNOWNSome other mystery problem!


Initialize encoding 44100hz 16-bit stereo sample data at 128kbps to a file called "out.wma", and set the header tag "Title" to "Something" in UTF-8 format.
Dim encoder As Integer = BassWma.BASS_WMA_EncodeOpenFile(44100, 2, 
                                 BASSWMAEncode.BASS_WMA_ENCODE_DEFAULT, 128000, "out.wma")
' set the title tag
BassWma.BASS_WMA_EncodeSetTag(encoder, "Title", "Something", BASSWMATag.BASS_WMA_TAG_UTF8)
int encoder = BassWma.BASS_WMA_EncodeOpenFile(44100, 2, 
                      BASSWMAEncode.BASS_WMA_ENCODE_DEFAULT, 128000, "out.wma");
// set the title tag
BassWma.BASS_WMA_EncodeSetTag(encoder, "Title", "Something", BASSWMATag.BASS_WMA_TAG_UTF8);
See Also