I have to admit your project has piqued my interest. So, listed below is starter code to read your MP3 file format. I have NOT thoroughly tested the code. That is your responsibility.
Next, I would suggest you develop a sorted doubly linked list to hold all of this info including the full path of the MP3 file. There is a demo of a sorted doubly LL on this forum somewhere that you may be able to use.
Once the LL is developed, we then move onto the GUI interface. The GUI interface will be used to activate a commercial MP3 player of your choice to play the selected MP3.
Code:
#include <windows.h>
#include <stdio.h>
struct sMP3ID3V1Struct
{
char szIdentity[3];
char szTitle[30];
char szArtist[30];
char szAlbum[30];
char szYear[4];
char szComment[28];
BYTE byteReserved;
BYTE byteTrackNum;
BYTE byteGenre;
};
char szArtist[30];
char szTitle[30];
char szAlbum[30];
char szComment[28];
char szYear[4];
BOOL OpenMP3(char * pFile)
{
HANDLE hFile = NULL;
if ((hFile = CreateFile(pFile,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL))
!= INVALID_HANDLE_VALUE)
{
DWORD dwNumBytesRead;
sMP3ID3V1Struct sID3V1Struct;
if (SetFilePointer(hFile,-128,NULL,FILE_END) != INVALID_SET_FILE_POINTER &&
ReadFile(hFile,&sID3V1Struct,128,&dwNumBytesRead,NULL) &&
dwNumBytesRead == 128 && memcmp(sID3V1Struct.szIdentity,"TAG",3) == 0)
{
memcpy(szTitle,sID3V1Struct.szTitle,30);
memcpy(szArtist,sID3V1Struct.szArtist,30);
memcpy(szAlbum,sID3V1Struct.szAlbum,30);
szYear[4] = 0;
memcpy( szYear,sID3V1Struct.szYear,4);
if (sID3V1Struct.byteReserved)
memcpy(szComment,sID3V1Struct.szComment,30);
else
memcpy(szComment,sID3V1Struct.szComment,28);
}
CloseHandle(hFile);
}
else
return FALSE;
return TRUE;
}
int main(int argc, char **argv)
{
if(argc > 1)
{
if(OpenMP3(argv[1]))
{
printf("artist: %s\n",szArtist);
printf("Title: %s\n",szTitle);
printf("album:%s\n", szAlbum);
printf("comment: %s\n", szComment);
printf("year: %s\n", szYear);
}
else
{
printf("Could not open %s\n", argv[1]);
return FALSE;
}
}
else
{
printf("MP3 file name not on command line\n");
return FALSE;
}
return TRUE;
}