Aby pobrać informacje na temat wykonawcy, tytułu, albumu, roku wydania oraz gatunku utworu z pliku MP3 to musimy odczytać jego ostatnie sektory. Ze względu na rozbudowaną strukturę tagów proponuję utworzyć osobny plik, w którym będzie znajdować się funkcją pobierająca dane …
Oto jego kod źródłowy :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
unit ID3; interface {$A+} { Honor packed } {$Z1} { Byte storage for small enumerated types } type //wykaz gatunków ID3Genre = ( id3gBlues, id3gClassicRock, id3gCountry, id3gDance, id3gDisco,id3gFunk, id3gGrunge, id3gHipHop, id3gJazz, id3gMetal, id3gNewAge, id3gOldies, id3gOther, id3gPop, id3gRNB, id3gRap, id3gReggae,id3gRock, id3gTechno, id3gIndustrial, id3gAlternative, id3gSka, id3gDeathMetal, id3gPranks, id3gSoundtrack, id3gEuroTechno,id3gAmbient, id3gTripHop, id3gVocal, id3gJazzFunk, id3gFusion,id3gTrance, id3gClassical, id3gInstrumental, id3gAcid, id3gHouse, id3gGame, id3gSoundClip, id3gGospel, id3gNoise, id3gAlternRock, id3gBass, id3gSoul, id3gPunk, id3gSpace, id3gMeditative, id3gInstrumentalPop, id3gInstrumentalRock, id3gEthnic, id3gGothic,id3gDarkwave, id3gTechnoIndustrial, id3gElectronic, id3gPopFolk, id3gEurodance, id3gDream, id3gSouthernRock, id3gComedy, id3gCult, id3gGangsta, id3gTop40, id3gChristianRap, id3gPopFunk, id3gJungle, id3gNativeAmerican, id3gCabaret, id3gNewWave, id3gPsychadelic, id3gRave, id3gShowtunes, id3gTrailer, id3gLoFi, id3gTribal, id3gAcidPunk, id3gAcidJazz, id3gPolka, id3gRetro, id3gMusical, id3gRockNRoll, id3gHardRock, id3gFolk, id3gFolkRock, id3gNationalFolk, id3gSwing, id3gFastFusion, id3gBebob, id3gLatin, id3gRevival, id3gCeltic, id3gBluegrass, id3gAvantgarde, id3gGothicRock, id3gProgressiveRock, id3gPsychedelicRock, id3gSymphonicRock, id3gSlowRock, id3gBigBand, id3gChorus, id3gEasyListening, id3gAcoustic, id3gHumour, id3gSpeech, id3gChanson, id3gOpera, id3gChamberMusic, id3gSonata, id3gSymphony, id3gBootyBass, id3gPrimus, id3gPornGroove, id3gSatire, id3gSlowJam, id3gClub, id3gTango, id3gSamba, id3gFolklore, id3gBallad,id3gPowerBallad, id3gRhythmicSoul, id3gFreestyle, id3gDuet, id3gPunkRock, id3gDrumSolo, id3gAcapella, id3gEuroHouse, id3gDanceHall ); ID3Struct = packed record Magic: array [0..2 ] of Char; //identyfikator Title: array [0..29] of Char; //tytuł Artist: array [0..29] of Char; //artysta Album: array [0..29] of Char; //album Year: array [0..3 ] of Char; //rok Comment: array [0..29] of Char; //komentarz Genre: ID3Genre; // gatunek end; const ID3Magic = 'TAG'; ID3OffsetFromEnd = 128; //odległość od końca pliku zarezerwowana dla tagów ID3UnknowGenre = ID3Genre(255); // nieznany gatunek //tablica gatunków ID3GenreName: array [ID3Genre] of PChar = ( 'Blues', 'Classic Rock', 'Country', 'Dance', 'Disco', 'Funk', 'Grunge', 'Hip-Hop', 'Jazz', 'Metal', 'New Age', 'Oldies', 'Other', 'Pop', 'R&B', 'Rap', 'Reggae', 'Rock', 'Techno', 'Industrial', 'Alternative', 'Ska', 'Death Metal', 'Pranks', 'Soundtrack', 'Euro-Techno', 'Ambient', 'Trip-Hop', 'Vocal', 'Jazz+Funk', 'Fusion', 'Trance', 'Classical', 'Instrumental', 'Acid', 'House', 'Game', 'Sound Clip', 'Gospel', 'Noise', 'AlternRock', 'Bass', 'Soul', 'Punk', 'Space', 'Meditative', 'Instrumental Pop', 'Instrumental Rock', 'Ethnic', 'Gothic', 'Darkwave', 'Techno-Industrial', 'Electronic', 'Pop-Folk', 'Eurodance', 'Dream', 'Southern Rock', 'Comedy', 'Cult', 'Gangsta', 'Top 40', 'Christian Rap', 'Pop/Funk', 'Jungle', 'Native American', 'Cabaret', 'New Wave', 'Psychadelic', 'Rave', 'Showtunes', 'Trailer', 'Lo-Fi', 'Tribal', 'Acid Punk', 'Acid Jazz', 'Polka', 'Retro', 'Musical', 'Rock & Roll', 'Hard Rock', 'Folk', 'Folk-Rock', 'National Folk', 'Swing', 'Fast Fusion', 'Bebob', 'Latin', 'Revival', 'Celtic', 'Bluegrass', 'Avantgarde', 'Gothic Rock', 'Progressive Rock', 'Psychedelic Rock', 'Symphonic Rock', 'Slow Rock', 'Big Band', 'Chorus', 'Easy Listening', 'Acoustic', 'Humour', 'Speech', 'Chanson', 'Opera', 'Chamber Music', 'Sonata', 'Symphony', 'Booty Bass', 'Primus', 'Porn Groove', 'Satire', 'Slow Jam', 'Club', 'Tango', 'Samba', 'Folklore', 'Ballad', 'Power Ballad', 'Rhythmic Soul', 'Freestyle', 'Duet', 'Punk Rock', 'Drum Solo', 'Acapella', 'Euro-House', 'Dance Hall' ); function GetMP3Infos(FN:String): id3struct; // FN - nazwa pliku implementation function GetMP3Infos(FN:String): id3struct; var F: File of Byte; Tag: ID3Struct; HasTag: Boolean; GenreName: String; NewFN: String; const Tab = #9; begin AssignFile(F, fn); try Reset(F); try Seek(F, FileSize(F) - ID3OffsetFromEnd); BlockRead(F, Tag, SizeOf(Tag)); HasTag := Tag.Magic = ID3Magic; if not HasTag then begin FillChar(Tag, Sizeof(Tag), ' '); Tag.Magic := ID3Magic; Tag.Genre := ID3UnknowGenre; end; CloseFile(f); Result:=Tag; except end; except end; end; end. |
Autor: Nakiel