Mp3tag is a library for reading the meta-data of mp3 audio files. Currently it supports only ID3v1.
Revision 2:f07a503ce8fe, committed 2011-01-26
- Comitter:
- christi_s
- Date:
- Wed Jan 26 17:53:29 2011 +0000
- Parent:
- 1:432c333ddb3a
- Commit message:
- add \"bool mp3tag_readTagFF(FIL* openFile, Id3V1Tag* tag)\"
Changed in this revision
mp3tag.cpp | Show annotated file Show diff for this revision Revisions of this file |
mp3tag.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 432c333ddb3a -r f07a503ce8fe mp3tag.cpp --- a/mp3tag.cpp Tue Jan 25 22:34:05 2011 +0000 +++ b/mp3tag.cpp Wed Jan 26 17:53:29 2011 +0000 @@ -92,6 +92,38 @@ return true; } +bool mp3tag_readTagFF(FIL* openFile, Id3V1Tag* tag) +{ + if (!openFile) + { + DEBUGOUT("MP3Tag: File not open.\r\n"); + return false; + } + // backup stream position + DWORD pos = openFile->fptr; + unsigned int n; + if ( (f_lseek(openFile, openFile->fsize - 128) != FR_OK) + || (f_read(openFile, tag, 128, &n) != FR_OK) + || n != 128) + { + DEBUGOUT("MP3Tag: Couldn't jump/read in file.\r\n"); + // restore stream position + f_lseek(openFile, pos); + return false; + } + + // restore stream position + f_lseek(openFile, pos); + if (strncmp(tag->tag, "TAG", 3)) + { + DEBUGOUT("MP3Tag: File doesn't have an ID3 tag.\r\n"); + return false; + } + DEBUGOUT("MP3Tag: GenreID %i.\r\n", tag->genre); + DEBUGOUT("MP3Tag: Tags readed.\r\n"); + return true; +} + char mp3tag_getTrackNumber(Id3V1Tag* tag) { if (tag->comment[28] == 0x00 && tag->comment[29] != 0x00)
diff -r 432c333ddb3a -r f07a503ce8fe mp3tag.h --- a/mp3tag.h Tue Jan 25 22:34:05 2011 +0000 +++ b/mp3tag.h Wed Jan 26 17:53:29 2011 +0000 @@ -28,6 +28,7 @@ #include <string.h> #include "defines.h" +#include "ff.h" #define MP3_ID3_TITLE_LENGTH 30 #define MP3_ID3_ARTIST_LENGTH 30 @@ -73,6 +74,18 @@ */ bool mp3tag_readTag(FILE* openFile, Id3V1Tag* tag); +/** Read id3tag from a file. + * + * @param openFile + * Open/readable audio file. (mp3) + * + * @param tag + * Return value with id3tag. + * + * @return TRUE on success, tag has the informations; FALSE on failure, tag isn't modiefied, openFile isn't open/readable or file has no id3v1. + */ +bool mp3tag_readTagFF(FIL* openFile, Id3V1Tag* tag); + /** Get track number from an id3tag. * * @param tag