Mega Code Archive

 
Categories / Delphi / Multimedia
 

Read the id3v1 information using bass dll

(* ------------------------------------------------------------ This Tip doesn't allow to change the ID3-Tag but it minimize the overhead for reading. BASS.DLL is a freeware library to handle with sound devices, allowing playing of MP3/MOD/.../WMA files and also recording, streaming from the web and so on. See for more information : http://www.un4seen.com/ ------------------------------------------------------------ *) (* ---------- "The easy way" utility unit ---------- *): unit B_ID3V1; interface uses Windows, Messages, SysUtils, Classes; type // some standard definition PID3V1Rec = ^TID3V1Rec; TID3V1Rec = packed record Tag: array[0..2] of Char; Title: array[0..29] of Char; Artist: array[0..29] of Char; Album: array[0..29] of Char; Year: array[0..3] of Char; Comment: array[0..29] of Char; Genre: Byte; end; const // some standard "genre". To be completed. cID3V1FGenre: array[0..147] of string = ('Blues', 'Classic Rock', 'Country', 'Dance',..., 'Synthpop'); function BASSID3ToID3V1Rec(PC: PChar): TID3V1Rec; implementation function BASSID3ToID3V1Rec(PC: PChar): TID3V1Rec; var TempID3V1: TID3V1Rec; // only for a better checking begin // fill the record with some dummy chars FillChar(Result, SizeOf(TID3V1Rec) - 1, '?'); // check to see if ther's something to map if (PC = nil) then Exit; // convert/copy to the record structure TempID3V1 := PID3V1Rec(PC)^; // check to see if it's really a ID3V1 Tag // else just give the dummy record back if SameText(TempID3V1.Tag, 'TAG') then Result := TempID3V1; end; (* ---------- How to use this function ---------- *) var ID3: TID3V1Rec; //... // after the Stream was initialized, // f.e. with the function "BASS_StreamCreateFile(...)" // after the Stream was initialized, // f.e. with the function "BASS_StreamCreateFile(...)" ID3:= BASSID3ToID3V1Rec( BASS_StreamGetTags(fStreamHandle, BASS_TAG_ID3) ); Showmessage( 'Title : ' + ID3.Title 'Artist : ' + ID3.Artist 'Year : ' + ID3.Year 'Comment : ' + ID3.Comment 'Genre : ' + cID3V1FGenre[ID3.Genre] );