1
Developers Corner / Id3v1 tag
« on: 23.02.2007 at 12:50:06 »
Not tested nor compiled for ypod... just a first try... Would be nice if someone could add code to get song length in sec...
Reference used: http://www.id3.org/ID3v1
I did not include the comment field.. Easy to do, but is it worth the bits ?
Some nice place.. helpers.h ?
extern char* pTitle;
extern char* pArti;
extern short sYear;
extern char cGenre;
At startup set all to NULL, ... main.c somewhere...
in helpers.c, function play_file
In the begining of function...
char* pCBuffer;
An then after:
if (playstate.ps_fd != NULL)
{
iprintf("open ok\n");
if (pTitle != NULL) free(pTitle);
if (pArti != NULL) free(pArti);
if (fatlseek(playstate.ps_fd, -128, SEEK_END ) != 0) {
pCBuffer = (char*)malloc(128);
FATFileRead(playstate.ps_fd, pCBuffer, 128);
if (memcmp(pCBuffer, "TAG", 3) == 0) {
pTitle = (char*)malloc(strlen(pCBuffer+3));
strcpy(pTitle,pCBuffer+3);
pArti = (char*)malloc(strlen(pCBuffer+33));
strcpy(pArti, pCBuffer+33);
sYear = ((pCBuffer[93]-48)*1000)+((pCBuffer[94]-48)*100)+((pCBuffer[95]-48)*10)+(pCBuffer[96]-48);
cGenre = pCBuffer[127];
}
free(pCBuffer);
}
fatlseek(fd,0,SEEK_SET);
}
/ToS
Reference used: http://www.id3.org/ID3v1
I did not include the comment field.. Easy to do, but is it worth the bits ?
Some nice place.. helpers.h ?
extern char* pTitle;
extern char* pArti;
extern short sYear;
extern char cGenre;
At startup set all to NULL, ... main.c somewhere...
in helpers.c, function play_file
In the begining of function...
char* pCBuffer;
An then after:
if (playstate.ps_fd != NULL)
{
iprintf("open ok\n");
if (pTitle != NULL) free(pTitle);
if (pArti != NULL) free(pArti);
if (fatlseek(playstate.ps_fd, -128, SEEK_END ) != 0) {
pCBuffer = (char*)malloc(128);
FATFileRead(playstate.ps_fd, pCBuffer, 128);
if (memcmp(pCBuffer, "TAG", 3) == 0) {
pTitle = (char*)malloc(strlen(pCBuffer+3));
strcpy(pTitle,pCBuffer+3);
pArti = (char*)malloc(strlen(pCBuffer+33));
strcpy(pArti, pCBuffer+33);
sYear = ((pCBuffer[93]-48)*1000)+((pCBuffer[94]-48)*100)+((pCBuffer[95]-48)*10)+(pCBuffer[96]-48);
cGenre = pCBuffer[127];
}
free(pCBuffer);
}
fatlseek(fd,0,SEEK_SET);
}
/ToS
