Hi, since there's no getMusicLenght command I decided to implement my own, presently only for mp3 music, I've searched all over the forum and found out
this
, but for some reason I can't seam to understand how the length is represented! I believe it's in milliseconds but I don't have any certainty
what I've done so far
char *filename = "C:\Download\FCUL\GDK\GDKShaders\BumpGloss\BumpGloss\UI 3.0\Teste\music\SW - Anakins Dark Deeds.mp3";
unsigned char* block = (unsigned char*)malloc(129);
FILE *file = NULL;
int fileSize = 0;
int startPos = 0;
int size = 0;
fpos_t position;
file = fopen(filename, "r");
fseek(file,0,SEEK_END);
fileSize = ftell(file);
rewind (file);
startPos = fileSize - 128;
position = startPos + 3;
fsetpos (file, &position);
char * teste = (char *)malloc(129);
unsigned char buffer[64];
//positions to get the title -- it works
fread(&buffer,1,30,file);
memcpy(teste,buffer,31);
//positions to get the length
position = startPos + 126;
fsetpos (file, &position);
//I assumed it was an integer (milisecconds)
fread(&buffer,1,4,file);
memcpy(&lenght,buffer,4);
EDIT: Supposelly this is the correct version, but it's not working
char *filename = "C:\Download\FCUL\GDK\GDKShaders\BumpGloss\BumpGloss\UI 3.0\Teste\music\SW - Anakins Dark Deeds.mp3";
unsigned char* block = (unsigned char*)malloc(129);
FILE *file = NULL;
int fileSize = 0;
int startPos = 0;
int size = 0;
fpos_t position;
file = fopen(filename, "r");
fseek(file,0,SEEK_END);
fileSize = ftell(file);
rewind (file);
startPos = fileSize - 128;
position = startPos + 3;
fsetpos (file, &position);
char * teste = (char *)malloc(128);
unsigned char buffer[64];
//positions to get the title -- it works
fread(&buffer,1,30,file);
memcpy(teste,buffer,31);
//positions to get the length
position = startPos + 124;
fsetpos (file, &position);
//I assumed it was an integer (milisecconds)
fread(&buffer,1,4,file);
memcpy(&lenght,buffer,4);