Navigation
Artikel
Stuff
RSS Feeds
|
Sourcecodes - MP3-Informationen auslesenSprachenübersicht/C / C++/ C#/Sonstiges Keywords: mp3 Header Informationen, Album, Titel, Artist, Jahr, Year, Kommentar, Comment, Genre, Kategorie Herzlichen Dank an Anton Staruschkin von www.cpp-programming.de/, für die Erlaubnis seine Quellcodes zu veröffentlichen.
Code: #include <iostream> #include <string> #include <windows.h> using namespace std; struct ID3V1 { char id[4]; char title[31]; char artist[31]; char album[31]; char year[5]; char comment[31]; char genre[2]; }; char *genres[] = { "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" }; int main() { char szMP3File[] = "test.mp3\0"; //Name der MP3 ID3V1 mp3_info; DWORD dwNumofBytes, dwFSize; HANDLE hMP3File = CreateFile(szMP3File, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); dwFSize = GetFileSize(hMP3File, NULL); SetFilePointer(hMP3File, -128, 0, FILE_END); ReadFile(hMP3File, mp3_info.id, 3, &dwNumofBytes, 0); if(!strstr(mp3_info.id, "TAG")) { mp3_info.title[0] = '\0'; mp3_info.artist[0] = '\0'; mp3_info.album[0] = '\0'; mp3_info.year[0] = '\0'; mp3_info.comment[0] = '\0'; mp3_info.genre[0] = '\0'; CloseHandle(hMP3File); return -1; } ReadFile(hMP3File, mp3_info.title, 30, &dwNumofBytes, NULL); ReadFile(hMP3File, mp3_info.artist, 30, &dwNumofBytes, NULL); ReadFile(hMP3File, mp3_info.album, 30, &dwNumofBytes, NULL); ReadFile(hMP3File, mp3_info.year, 4, &dwNumofBytes, NULL); ReadFile(hMP3File, mp3_info.comment, 30, &dwNumofBytes, NULL); ReadFile(hMP3File, &mp3_info.genre[0], 1, &dwNumofBytes, NULL); mp3_info.album[30] = '\0'; mp3_info.artist[30] = '\0'; mp3_info.comment[30] = '\0'; mp3_info.genre[1] = '\0'; mp3_info.title[30] = '\0'; mp3_info.year[4] = '\0'; cout<<"MP3: "<<szMP3File<<endl <<"Titel: "<<mp3_info.title<<endl <<"Kuenstler: "<<mp3_info.artist<<endl <<"Album "<<mp3_info.album<<endl <<"Jahr: "<<mp3_info.year<<endl <<"Kommentar: "<<mp3_info.comment<<endl <<"Genre: "<<genres[(int)mp3_info.genre[0]]<<endl; cin.get(); return 0; } Gibt es noch irgendwelche Fragen, oder wollen Sie über den Artikel diskutieren? Sprachenübersicht/C / C++/ C#/Sonstiges/MP3-Informationen auslesen |