Namespace: Un4seen.Bass
Assembly: Bass.Net (in Bass.Net.dll) Version: 2.4.17.5
[DllImportAttribute("bass")] public static IntPtr BASS_ChannelGetTags( int handle, BASSTag tags )
Parameters
- handle
- Type: SystemInt32
The channel handle...a HMUSIC or HSTREAM. - tags
- Type: Un4seen.BassBASSTag
The tags/headers wanted... one of the following (see BASSTag):Other tags may be supported by Add-Ons, see the documentation.BASS_TAG_AM_MIME Android media codec MIME type. A single string is returned. BASS_TAG_AM_NAME Android media codec name. A single string is returned. This in only available on Android 4.3 and above. BASS_TAG_APE APE (v1 or v2) tags. A pointer to a series of null-terminated UTF-8 strings is returned, the final string ending with a double null. Each string is in the form of "key=value", or "key=value1/value2/..." if there are multiple values. BASS_TAG_APE_BINARY + tag number (0=first). APEv2 binary tag. A pointer to a BASS_TAG_APE_BINARY structure is returned. BASS_TAG_CA_CODEC CoreAudio codec information. A pointer to a BASS_TAG_CACODEC structure is returned. BASS_TAG_HTTP HTTP headers, only available when streaming from a HTTP server. A pointer to a series of null-terminated strings is returned, the final string ending with a double null. BASS_TAG_ICY ICY (Shoutcast) tags. A pointer to a series of null-terminated strings is returned, the final string ending with a double null. BASS_TAG_ID3 ID3v1 tags. A pointer to a 128 byte block is returned. See www.id3.org for details of the block's structure. BASS_TAG_ID3V2 ID3v2 tags. A pointer to a variable length block is returned. See www.id3.org for details of the block's structure. ID3v2 tags are supported at both the start and end of the file. BASS_TAG_ID3V2_2 A second ID3v2 tag block (if one is present after the first block). BASS_TAG_LOCATION The final URL after HTTP redirection. BASS_TAG_LYRICS3 Lyrics3v2 tag. A single string is returned, containing the Lyrics3v2 information. See www.id3.org/Lyrics3v2 for details of its format. BASS_TAG_META Shoutcast metadata. A single null-terminated string containing the current stream title and url (usually omitted). The format of the string is: StreamTitle='xxx';StreamUrl='xxx'; BASS_TAG_MF Media Foundation metadata. A pointer to a series of null-terminated UTF-8 strings is returned, the final string ending with a double null. BASS_TAG_MP4 MP4/iTunes metadata. A pointer to a series of null-terminated UTF-8 strings is returned, the final string ending with a double null. BASS_TAG_MUSIC_AUTH MOD music author. Only available in files created with the OpenMPT tracker. BASS_TAG_MUSIC_CHAN + channel number (0=first). MOD channel name. Only available in files created with the OpenMPT tracker. BASS_TAG_MUSIC_INST + instrument number (0=first). MOD instrument name (a single null-terminated ANSI String). BASS_TAG_MUSIC_MESSAGE MOD message text (a single null-terminated ANSI String). BASS_TAG_MUSIC_NAME MOD music title (a single null-terminated ANSI String). BASS_TAG_MUSIC_ORDERS MOD music order list. A pointer to a byte array is returned, with each byte being the pattern number played at that order position. Pattern number 254 is "+++" (skip order) and 255 is "---" (end song). BASS_TAG_MUSIC_SAMPLE + sample number (0=first). MOD sample name (a single null-terminated ANSI String). BASS_TAG_OGG OGG comments, only available when streaming an OGG file. A pointer to a series of null-terminated UTF-8 strings is returned, the final string ending with a double null. BASS_TAG_RIFF_BEXT RIFF/BWF "bext" chunk tags. A pointer to a BASS_TAG_BEXT structure is returned. BASS_TAG_RIFF_CART RIFF/BWF "cart" chunk tags. A pointer to a BASS_TAG_CART structure is returned. BASS_TAG_RIFF_CUE RIFF/CUE "cue" chunk tags. A pointer to a BASS_TAG_CUE structure is returned. BASS_TAG_RIFF_DISP RIFF/WAVE 'DISP' chunk text (CF_TEXT) tag. A single string is returned. BASS_TAG_RIFF_INFO RIFF/WAVE 'INFO' tags. A pointer to a series of null-terminated ANSI strings is returned, the final string ending with a double null. The tags are in the form of 'XXXX=text', where 'XXXX' is the chunk ID. BASS_TAG_RIFF_SMPL RIFF/SMPL "smpl" chunk tags. A pointer to a BASS_TAG_SMPL structure is returned. BASS_TAG_VENDOR OGG encoder. A single UTF-8 string is returned. BASS_TAG_WAVEFORMAT WAVE 'fmt' chunk contents. A pointer to a WAVEFORMATEX structure is returned. As well as WAVE files, this is also provided by Media Foundation codecs. BASS_TAG_WMA WMA tags. A pointer to a series of null-terminated UTF-8 strings is returned, the final string ending with a double null.
Return Value
Type: IntPtrIf succesful, a pointer to the data of the tags/headers is returned, else Zero is returned. Use BASS_ErrorGetCode to get the error code.
In a chained OGG file containing multiple bitstreams, each bitstream will have its own tags. To get the tags from a particular one, BASS_ChannelSetPosition(Int32, Int64, BASSMode) can be first used to seek to it.
When a Media Foundation codec is in use, the BASS_TAG_WAVEFORMAT tag can be used to find out what the source format is, eg. via the WAVEFORMATEX structure's wFormatTag member. Some typical wFormatTag examples are: 0x0161 = WMA, 0x0162 = WMA pro, 0x0163 = WMA lossless, 0x1610 = AAC.
MP4 metadata can include a "Genre" tag that is either text or a number. When a number, it is an ID3v1 genre list index +1, eg. 1 = Blues, 2 = Classic Rock, etc. The full list can be found at id3.org.
The returned tag's memory is owned by BASS (or an add-on) and should not be modified. It should also not be accessed after the channel has been freed. If longer-term access is needed, a copy should be made.
You might also use one of these overloads to directly get specific tags: BASS_ChannelGetTagsBWF(Int32), BASS_ChannelGetTagsCA(Int32), BASS_ChannelGetTagsID3V1(Int32), BASS_ChannelGetTagsID3V2(Int32, IntPtr), BASS_ChannelGetTagsAPE(Int32), BASS_ChannelGetTagsAPEBinary(Int32), BASS_ChannelGetTagsAPEPictures(Int32), BASS_ChannelGetTagsWMA(Int32), BASS_ChannelGetTagsMP4(Int32), BASS_ChannelGetTagsMF(Int32), BASS_ChannelGetTagsWAVEFORMAT(Int32), BASS_ChannelGetTagsFLACPictures(Int32), BASS_ChannelGetTagsFLACCuesheet(Int32), BASS_ChannelGetTagsOGG(Int32), BASS_ChannelGetTagsDSDArtist(Int32), BASS_ChannelGetTagsDSDTitle(Int32), BASS_ChannelGetTagsDSDComments(Int32), BASS_ChannelGetTagsHTTP(Int32), BASS_ChannelGetTagsICY(Int32), BASS_ChannelGetTagsRIFF(Int32), BASS_ChannelGetTagsMETA(Int32), BASS_ChannelGetTagLyrics3v2(Int32), BASS_ChannelGetMusicName(Int32), BASS_ChannelGetMusicSample(Int32, Int32), BASS_ChannelGetMusicInstrument(Int32, Int32), BASS_ChannelGetMusicMessage(Int32), BASS_ChannelGetMidiTrackText(Int32, Int32).
In addition you might also use the BassTags class, which provides extended TAG reading support.
ERROR CODE | Description |
---|---|
BASS_ERROR_HANDLE | handle is not valid. |
BASS_ERROR_NOTAVAIL | The requested tags are not available. |
int channel = Bass.BASS_StreamCreateFile("test.ogg", 0, 0, BASSFlag.BASS_SAMPLE_FLOAT); IntPtr tag = Bass.BASS_ChannelGetTags(channel, BASSTag.BASS_TAG_OGG); string[] tags = Utils.IntPtrToArrayNullTermUtf8(tag); if (tags != null) { foreach (string tag in tags) Console.Writeln("Tag: {0}\n", tag); }
IntPtr p = BASS_ChannelGetTags(handle, (BASSTag)(BASSTag.BASS_TAG_MUSIC_INST + instrument)); if (p != IntPtr.Zero) string instr = Utils.IntPtrAsStringAnsi(p);